Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace midprepare
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10.  
  11. string[] arr = Console.ReadLine().Split('|');
  12. string command = Console.ReadLine();
  13. while (command != "Done")
  14. {
  15. string[] action = command.Split();
  16. if (action[0] == "Move")
  17. {
  18. int index = int.Parse(action[2]);
  19. if (action[1] == "Left")
  20. {
  21. if (index > 0 && index < arr.Length)
  22. {
  23. string temp = arr[index];
  24. arr[index] = arr[index - 1];
  25. arr[index - 1] = temp;
  26. }
  27. }
  28. if (action[1] == "Right")
  29. {
  30. if (index >= 0 && index < arr.Length - 1)
  31. {
  32. string temp = arr[index];
  33. arr[index] = arr[index + 1];
  34. arr[index + 1] = temp;
  35. }
  36.  
  37. }
  38.  
  39. }
  40.  
  41. if (action[0] == "Check")
  42. {
  43. int n = 0;
  44. if (action[1] == "Odd")
  45. {
  46. n = 1;
  47. }
  48. for (int i = 0; i < arr.Length; i++)
  49. {
  50. if (i % 2 == n)
  51. {
  52. Console.Write(arr[i] + " ");
  53.  
  54. }
  55. }
  56. Console.WriteLine();
  57. }
  58.  
  59.  
  60. command = Console.ReadLine();
  61. }
  62.  
  63. Console.WriteLine($"You crafted { string.Join("", arr)}!");
  64. }
  65.  
  66.  
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement