boykopk

Untitled

Nov 25th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 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. namespace P02.Icarus
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var planes = Console.ReadLine()
  14. .Split(' ')
  15. .Select(int.Parse)
  16. .ToArray();
  17.  
  18. int startPosition = int.Parse(Console.ReadLine());
  19.  
  20. string[] command = Console.ReadLine()
  21. .Split(' ');
  22.  
  23. int damage = 1;
  24.  
  25. while (command[0] != "Supernova")
  26. {
  27.  
  28. int steps = int.Parse(command[1]);
  29.  
  30. if (command[0] == "right")
  31. {
  32. while (steps >= 1)
  33. {
  34. if (startPosition == planes.Length - 1)
  35. {
  36. startPosition = -1;
  37. damage++;
  38. }
  39.  
  40. startPosition++;
  41. planes[startPosition] -= damage;
  42. steps--;
  43. }
  44. }
  45. else if (command[0] == "left")
  46. {
  47. while (steps >= 1)
  48. {
  49. if (startPosition == 0)
  50. {
  51. startPosition = planes.Length;
  52. damage++;
  53. }
  54.  
  55. startPosition--;
  56. planes[startPosition] -= damage;
  57. steps--;
  58. }
  59. }
  60.  
  61. command = Console.ReadLine().Split(' ');
  62. }
  63.  
  64. Console.WriteLine(string.Join(" ", planes));
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment