Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace ExtractPersonInformation
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int numberOfLines = int.Parse(Console.ReadLine());
- for (int i = 0; i < numberOfLines; i++)
- {
- string text = Console.ReadLine();
- int startIndexName = text.IndexOf('@')+1;
- int endIndexName = text.IndexOf('|');
- int nameLength = endIndexName - startIndexName;
- string name = text.Substring(startIndexName, nameLength);
- int startIndexAge = text.IndexOf('#')+1;
- int endIndexAge = text.IndexOf('*');
- int ageLength = endIndexAge - startIndexAge;
- string age = text.Substring(startIndexAge, ageLength);
- Console.WriteLine($"{name} is {age} years old.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement