Advertisement
SavaIv

Untitled

Jan 15th, 2020
132
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.  
  3. namespace _06._High_Jump
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int hightTarget = int.Parse(Console.ReadLine());
  10.  
  11. int hightActual = hightTarget - 30;
  12.  
  13. int jumpCounterTotal = 0;
  14. int jumpCounterFail = 0;
  15.  
  16. while (true)
  17. {
  18.  
  19. int hightJump = int.Parse(Console.ReadLine());
  20. jumpCounterTotal++;
  21.  
  22. if (hightJump > hightActual)
  23. {
  24. jumpCounterFail = 0;
  25.  
  26. if (hightActual >= hightTarget)
  27. // Be careful here – “if” check with the hightJump (instead hightActual)
  28. // the result will be “successful” exit without the heghtTarget to be reached.
  29. // For example: if the first jump is > hightTarget.
  30. {
  31. Console.WriteLine("Tihomir succeeded, he jumped over {0}cm after {1} jumps.", hightTarget, jumpCounterTotal);
  32. break;
  33. }
  34. else
  35. {
  36. hightActual += 5;
  37. continue;
  38. }
  39.  
  40. }
  41. else
  42. {
  43. jumpCounterFail++;
  44.  
  45. if(jumpCounterFail == 3)
  46. {
  47. Console.WriteLine("Tihomir failed at {0}cm after {1} jumps.", hightActual, jumpCounterTotal);
  48. break;
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement