Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _01._Problem
- {
- class Program
- {
- static void Main(string[] args)
- {
- string str = Console.ReadLine();
- string line = string.Empty;
- while ((line = Console.ReadLine())!= "Done")
- {
- string command = line.Split(" ")[0];
- if (command == "Change")
- {
- var ch = line.Split(" ")[1].ToCharArray();
- var repl = line.Split(" ")[2];
- str = new string(str.Select(r => r == ch[0] ? (char)(repl[0]) : r).ToArray());
- Console.WriteLine(str);
- }
- else if (command == "Includes")
- {
- var isIncluded = line.Split(" ")[1];
- if (str.Contains(isIncluded))
- {
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
- }
- else if (command == "End")
- {
- var endsWith = line.Split(" ")[1];
- if (str.EndsWith(endsWith))
- {
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
- }
- else if (command == "Uppercase")
- {
- str = str.ToUpper();
- Console.WriteLine(str);
- }
- else if (command == "FindIndex")
- {
- var ch = line.Split(" ")[1].ToCharArray();
- Console.WriteLine(str.IndexOf(ch[0]));
- }
- else if (command == "Cut")
- {
- int startIndex = int.Parse(line.Split(" ")[1]);
- int length = int.Parse(line.Split(" ")[2]);
- str = str.Substring(startIndex, length);
- Console.WriteLine(str);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement