Advertisement
Spocoman

01. Extract Person Information

Apr 16th, 2023
963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5.  
  6. namespace ExtractPersonInformation
  7. {
  8.  
  9.     class Program
  10.     {
  11.         static string SubFinder(string str, char start, char end)
  12.         {
  13.             int startIndex = str.IndexOf(start) + 1;
  14.             int endIndex = str.IndexOf(end);
  15.             int length = endIndex - startIndex;
  16.  
  17.             return str.Substring(startIndex, length);
  18.         }
  19.  
  20.         static void Main()
  21.         {
  22.             int n = int.Parse(Console.ReadLine());
  23.  
  24.             for (int i = 0; i < n; i++)
  25.             {
  26.                 string text = Console.ReadLine();
  27.                 Console.WriteLine($"{SubFinder(text, '@', '|')} is {SubFinder(text, '#', '*')} years old.");
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement