Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace String_Manipulator
- {
- class Program
- {
- static void Main(string[] args)
- {
- string sb = "";
- while (true)
- {
- string text = Console.ReadLine();
- if (text == "End")
- {
- break;
- }
- else
- {
- if (text == "Print")
- {
- Console.WriteLine(sb);
- }
- else
- {
- string[] data = text.Split(' ');
- string command = data[0];
- if (command == "Add")
- {
- string currentString = data[1];
- sb += currentString;
- }
- else if (command == "Upgrade")
- {
- char currentSymbol = char.Parse(data[1]);
- sb = sb.Replace(currentSymbol, (char)(currentSymbol + 1));
- }
- else if (command == "Index")
- {
- char currentSymbol = char.Parse(data[1]);
- bool isThereLookingSymbol = false;
- for (int i = 0; i < sb.Length; i++)
- {
- char currentChar = sb[i];
- if (currentSymbol == currentChar)
- {
- Console.Write($"{i} ");
- isThereLookingSymbol = true;
- }
- }
- Console.WriteLine();
- if (isThereLookingSymbol == false)
- {
- Console.WriteLine("None");
- }
- }
- else if (command == "Remove")
- {
- string stringForRemoving = data[1];
- while (true)
- {
- if (sb.Contains(stringForRemoving))
- {
- sb = sb.Replace(stringForRemoving, "");
- }
- else
- {
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment