Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace next
- {
- class Program
- {
- static void Main(string[] args)
- {
- string title = Console.ReadLine();
- // input word
- int lines = int.Parse(Console.ReadLine());
- // number of words
- int index = 0;
- for (int i = 0; i < lines; i++)
- {
- string word = Console.ReadLine().ToLower();
- //the sequence to search in the "title"
- string temp = title;
- //string to manipulate while keeping "title", so if the sequence is not found
- // the original string is unchanged
- int count = 0;
- for (int j = 0; j < word.Length; j++)
- {
- if (temp.IndexOf(word[j], index) > -1)
- {
- index = temp.IndexOf(word[j], index);
- string firstPart = temp.Substring(0, index);
- string secondPart = temp.Substring(index + 1, temp.Length - index - 1);
- temp = firstPart + secondPart;
- count++;
- }
- else
- {
- break;
- }
- }
- if (count == word.Length)
- {
- Console.WriteLine(temp);
- title = temp;
- index = 0;
- }
- else
- {
- Console.WriteLine("No such title found!");
- index = 0;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement