Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. namespace _03.Present_Delivery
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int[] numbers = Console.ReadLine().Split('@').Select(int.Parse).ToArray();
  13.  
  14. string input = string.Empty;
  15. int santaIndex = 0;
  16.  
  17.  
  18. while ((input = Console.ReadLine()) != "Merry Xmas!")
  19. {
  20. string[] command = input.Split().ToArray();
  21.  
  22. if (command[0] == "Jump")
  23. {
  24. int lenght = int.Parse(command[1]);
  25. int size = numbers.Length;
  26. if (santaIndex + lenght >= numbers.Length)
  27. {
  28. santaIndex += lenght;
  29.  
  30. while (size < santaIndex)
  31. {
  32. size = size + numbers.Length;
  33. }
  34. int index = size - santaIndex;
  35. numbers[index] -= 2;
  36.  
  37. santaIndex = 0;
  38. numbers[santaIndex] -= 2;
  39.  
  40.  
  41. //int test = santaIndex - numbers.Length;
  42. //santaIndex += test;
  43. }
  44. else
  45. {
  46.  
  47. santaIndex += lenght;
  48. numbers[santaIndex] -= 2; //dali veche ne e 0
  49. }
  50. }
  51. }
  52. }
  53. }
  54. //while (santaIndex > numbers.Length)
  55. //{
  56. // if (santaIndex >= numbers.Length)
  57. // {
  58. // test = santaIndex - numbers.Length;
  59. // santaIndex = 0;
  60. // santaIndex += test;
  61. // }
  62. // else
  63. // {
  64. // numbers[santaIndex] -= 2;
  65. // }
  66. //}
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement