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