Advertisement
tochka

Untitled

Jan 27th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Globalization;
  7. using System.Numerics;
  8.  
  9. namespace ConsoleApp97
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. List<string> text = Console.ReadLine()
  16. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
  17. .ToList();
  18.  
  19. int n = int.Parse(Console.ReadLine());
  20.  
  21.  
  22. for (int i = 1; i <= n; i++)
  23. {
  24. string[] commands = Console.ReadLine().Split(' ').ToArray();
  25.  
  26. if (commands[0] == "Reverse")
  27. {
  28. text.Reverse();
  29. }
  30.  
  31.  
  32. if(commands[0] == "Replace")
  33. {
  34. int index = int.Parse(commands[1]);
  35. string element = commands[2];
  36. text.RemoveAt(index);
  37. text.Insert(index, element);
  38. }
  39.  
  40. if (commands[0] == "Distinct")
  41. {
  42. text = text.Distinct().ToList();
  43. }
  44. }
  45. Console.WriteLine(string.Join(", ", text));
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement