Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace Playing
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- string command = string.Empty;
- while (command != "Done")
- {
- command = Console.ReadLine();
- string[] tokens = command.Split().ToArray();
- if (tokens[0] == "Change")
- {
- text = text.Replace(tokens[1], tokens[2]);
- Console.WriteLine(text);
- }
- else if (tokens[0] == "Includes")
- {
- if (text.Contains(tokens[1]))
- {
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
- }
- else if (tokens[0] == "End")
- {
- if (text.Contains(tokens[1]))
- {
- int firstIndex = text.IndexOf(tokens[1]);
- int lastIndex = text.LastIndexOf(tokens[1]);
- if (lastIndex == text.Length - 1)
- {
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
- }
- }
- else if (tokens[0] == "Uppercase")
- {
- text = text.ToUpper();
- Console.WriteLine(text);
- }
- else if (tokens[0] == "FindIndex")
- {
- int index = text.IndexOf(tokens[1]);
- Console.WriteLine(index);
- }
- else if (tokens[0] == "Cut")
- {
- int startIndex = int.Parse(tokens[1]);
- int length = int.Parse(tokens[2]);
- string removed = string.Empty;
- for (int i = startIndex; i <= startIndex + length - 1; i++)
- {
- removed += text[i];
- }
- text = text.Remove(startIndex, length);
- Console.WriteLine(removed);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment