Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- class Program
- {
- static void Main()
- {
- var input = Console.ReadLine();
- string command = Console.ReadLine();
- while (command != "End")
- {
- string[] line = command.Split();
- string cmd = line[0];
- if (cmd == "Translate")
- {
- var oldChar = line[1];
- var newChar = line[2];
- input = input.Replace(oldChar, newChar);
- Console.WriteLine(input);
- }
- else if (cmd == "Includes")
- {
- string isContains = line[1];
- if (input.Contains(isContains))
- {
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
- }
- else if (cmd == "Lowercase")
- {
- input = input.ToLower();
- Console.WriteLine(input);
- }
- else if (cmd == "FindIndex")
- {
- var index = line[1];
- int indexOf = input.LastIndexOf(index);
- Console.WriteLine(indexOf);
- }
- else if (cmd == "Start")
- {
- StringBuilder sb = new StringBuilder();
- string isSame = line[1];
- bool isTrue = true;
- while (isTrue)
- {
- for (int i = 0; i < input.Length; i++)
- {
- var diff = input[i].ToString();
- if(diff == " ")
- {
- isTrue = false;
- break;
- }
- else if(diff != " ")
- {
- sb.Append(diff);
- }
- }
- }
- if(isSame == sb.ToString())
- {
- Console.WriteLine("True");
- }
- else
- {
- Console.WriteLine("False");
- }
- }
- else if (cmd == "Remove")
- {
- int startIndex = int.Parse(line[1]);
- int endIndex = int.Parse(line[2]);
- input = input.Remove(startIndex, endIndex);
- Console.WriteLine(input);
- }
- command = Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment