Advertisement
silvana1303

secret chat

Jul 25th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Text;
  5. using System.Linq;
  6.  
  7. namespace _01._Furniture
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string input = Console.ReadLine();
  14.  
  15.             string[] command = Console.ReadLine().Split(":|:").ToArray();
  16.  
  17.             while (command[0] != "Reveal")
  18.             {
  19.                 if (command[0] == "InsertSpace")
  20.                 {
  21.                     int index = int.Parse(command[1]);
  22.                     input = input.Insert(index, " ");
  23.                 }
  24.                 if (command[0] == "Reverse")
  25.                 {
  26.                     if (input.Contains(command[1]))
  27.                     {
  28.                         int index = input.IndexOf(command[1]);
  29.                         input = input.Remove(index, command[1].Length);
  30.  
  31.                         char[] charArray = command[1].ToCharArray();
  32.                         Array.Reverse(charArray);
  33.                         string reversed = new string(charArray);
  34.                         input = string.Concat(input, reversed);
  35.                     }
  36.                     else
  37.                     {
  38.                         Console.WriteLine("error");
  39.                         command = Console.ReadLine().Split(":|:").ToArray();
  40.                         continue;
  41.                     }
  42.                 }
  43.                 if (command[0] == "ChangeAll")
  44.                 {
  45.                     if (input.Contains(command[1]))
  46.                     {
  47.                         input = input.Replace(command[1], command[2]);
  48.                     }
  49.                 }
  50.  
  51.                 Console.WriteLine(input);
  52.                 command = Console.ReadLine().Split(":|:").ToArray();
  53.             }
  54.  
  55.             Console.WriteLine($"You have a new text message: {input}");
  56.  
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement