Guest User

title

a guest
Feb 18th, 2023
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. class Program
  7. {
  8.     static void Main()
  9.     {
  10.         string title = Console.ReadLine();
  11.         int lines = int.Parse(Console.ReadLine());
  12.         string result = title;
  13.         for (int i = 0; i < lines; i++)
  14.         {
  15.             string target = Console.ReadLine();
  16.             int targetIndex = 0;
  17.             for (int j = 0; j < result.Length; j++)
  18.             {
  19.                 char searched = target[targetIndex];
  20.                 char found = result[j];
  21.                 if (found == searched)
  22.                 {
  23.                     string temp = result.Remove(j, 1);
  24.                     result = temp;
  25.                     targetIndex++;
  26.                     j--;
  27.                 }
  28.                 if (targetIndex == target.Length)
  29.                 {
  30.                     title = result;
  31.                     Console.WriteLine(string.Join("", title));
  32.                     break;
  33.                 }
  34.             }
  35.             if (targetIndex != target.Length)
  36.             {
  37.                 result = title;
  38.                 Console.WriteLine("No such title found!");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment