Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. int[] thePlane = Console.ReadLine()
  2. .Split()
  3. .Select(int.Parse)
  4. .ToArray();
  5. int startingPosition = int.Parse(Console.ReadLine());
  6. string comand = Console.ReadLine();
  7. int damage = 1;
  8.  
  9. while (comand!="Supernova")
  10. {
  11. string[] arr = comand.Split();
  12. string dirction = arr[0];
  13. int step = int.Parse(arr[1]);
  14.  
  15. switch (dirction)
  16. {
  17. case "left":
  18. for (int i = 0; i < step; i++)
  19. {
  20. startingPosition--;
  21. if (startingPosition<0)//-1,ako izlezne ot masiva
  22. {
  23. startingPosition = thePlane.Length - 1;
  24. damage++;
  25. }
  26. thePlane[startingPosition] -= damage;
  27. }
  28. break;
  29. case "right":
  30. for (int i = 0; i < step; i++)
  31. {
  32. startingPosition++;
  33. if (startingPosition>thePlane.Length-1)
  34. {
  35. startingPosition = 0;
  36. damage++;
  37. }
  38. thePlane[startingPosition] -= damage;
  39. }
  40. break;
  41. }
  42. comand = Console.ReadLine();
  43. }
  44. Console.WriteLine(string.Join(" ",thePlane));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement