Advertisement
madeofglass

Untitled

Feb 19th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.HighJump
  4. {
  5.     class HighJump
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int height = int.Parse(Console.ReadLine());
  10.  
  11.             int startheight = height - 30;
  12.             int numJumps = 0;
  13.             int fail = 0;
  14.  
  15.             while (true)
  16.             {
  17.                 int jump = int.Parse(Console.ReadLine());
  18.                 numJumps++;
  19.  
  20.                 if (startheight < jump)
  21.                 {
  22.                     if (startheight >= height)
  23.                     {
  24.                         break;
  25.                     }
  26.                     startheight += 5;
  27.                     fail = 0;
  28.                 }
  29.                 else
  30.                 {
  31.                     fail++;
  32.                 }
  33.  
  34.                 if (fail == 3)
  35.                 {
  36.                     break;
  37.                 }
  38.  
  39.                 //else if (startheight >= height)
  40.                 //{
  41.                 //    numJumps += 1;
  42.                 //    break;
  43.                 //}
  44.             }
  45.             if (fail == 3)
  46.             {
  47.                 Console.WriteLine($"Tihomir failed at {startheight}cm after {numJumps} jumps.");
  48.             }
  49.  
  50.             else if (startheight >= height)
  51.             {
  52.                 Console.WriteLine($"Tihomir succeeded, he jumped over {startheight}cm after {numJumps} jumps.");
  53.             }
  54.  
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement