Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _09MelrahShake
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string pattern = Console.ReadLine();
- while (input.Length>0 && pattern.Length>0)
- {
- int firstIndex = input.IndexOf(pattern);
- int lastIndex = input.LastIndexOf(pattern);
- if (firstIndex>=0 && lastIndex>=0 && firstIndex!=lastIndex)
- {
- input = input.Remove(firstIndex, pattern.Length);
- lastIndex = input.LastIndexOf(pattern);
- input = input.Remove(lastIndex, pattern.Length);
- pattern = pattern.Remove(pattern.Length / 2, 1);
- Console.WriteLine("Shaked it.");
- }
- else
- {
- break;
- }
- }
- Console.WriteLine("No shake.");
- Console.WriteLine(input);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement