Guest User

Untitled

a guest
Nov 5th, 2017
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 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.  
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. string readLine = Console.ReadLine();
  12. string[] stringArray = readLine.Split(' ');
  13. var newArray = stringArray;
  14. int replaceNumber;
  15.  
  16. var n = int.Parse(Console.ReadLine());
  17. for (int i = 0; i < n; i++)
  18. {
  19.  
  20. string readFunction = Console.ReadLine();
  21. var function = readFunction.Split(' ');
  22. if (function[0] == "Reverse")
  23. {
  24. stringArray = newArray;
  25. Array.Reverse(stringArray);
  26. stringArray = newArray;
  27. }
  28. else if (function[0] == "Distinct")
  29. {
  30. newArray = stringArray.Distinct().ToArray();
  31. }
  32. else if (function[0] == "Replace")
  33. {
  34. replaceNumber = int.Parse(function[1]);
  35. stringArray = newArray;
  36. newArray = stringArray.Select(x => x.Replace(stringArray[replaceNumber], function[2])).ToArray();
  37. stringArray = newArray;
  38. }
  39. }
  40. Console.WriteLine(String.Join(", ", newArray));
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment