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 = -1;
- for (int i = 0; i < lines; i++)
- {
- string word = Console.ReadLine().ToLower();
- //the sequence to surch in the "title"
- string temp = title;
- //string to manipulate while keeping "title", so if the sequence is not found
- // the original string is unchanged
- if (word.Length>title.Length)
- {
- Console.WriteLine("No such title found!");
- index = 2;
- continue;
- }
- for (int j = 0; j < word.Length; j++)
- {
- index = temp.IndexOf(word[j].ToString());
- if (index > -1)
- {
- temp = temp.Remove(index, 1);
- index = -1;
- if (j == word.Length-1)
- {
- index = 1;
- }
- }
- }
- if (index == 1)
- {
- Console.WriteLine(temp);
- title = temp;
- }
- else if(index == -1)
- {
- Console.WriteLine("No such title found!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement