Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Text;
- using System.Linq;
- namespace _01._Furniture
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string[] command = Console.ReadLine().Split(":|:").ToArray();
- while (command[0] != "Reveal")
- {
- if (command[0] == "InsertSpace")
- {
- int index = int.Parse(command[1]);
- input = input.Insert(index, " ");
- }
- if (command[0] == "Reverse")
- {
- if (input.Contains(command[1]))
- {
- int index = input.IndexOf(command[1]);
- input = input.Remove(index, command[1].Length);
- char[] charArray = command[1].ToCharArray();
- Array.Reverse(charArray);
- string reversed = new string(charArray);
- input = string.Concat(input, reversed);
- }
- else
- {
- Console.WriteLine("error");
- command = Console.ReadLine().Split(":|:").ToArray();
- continue;
- }
- }
- if (command[0] == "ChangeAll")
- {
- if (input.Contains(command[1]))
- {
- input = input.Replace(command[1], command[2]);
- }
- }
- Console.WriteLine(input);
- command = Console.ReadLine().Split(":|:").ToArray();
- }
- Console.WriteLine($"You have a new text message: {input}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement