SvetlanPetrova

High Jump SoftUni

Apr 3rd, 2019 (edited)
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace HighJump
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int targetHight = int.Parse(Console.ReadLine());
  10.             int poleHight = targetHight - 30;
  11.             int jumpHight = 0;
  12.             int jumpsCounter = 0;
  13.             int failedJumpsCounter = 0;
  14.  
  15.             while (jumpHight <= targetHight)
  16.             {
  17.                
  18.                 jumpHight = int.Parse(Console.ReadLine());
  19.                 jumpsCounter++;
  20.                 if (jumpHight <= poleHight)
  21.                 {
  22.                     failedJumpsCounter++;
  23.                     if (failedJumpsCounter == 3)
  24.                     {
  25.                         Console.WriteLine($"Tihomir failed at {poleHight}cm after {jumpsCounter} jumps.");
  26.                         break;
  27.                     }
  28.                 }
  29.                 else if (jumpHight > poleHight)
  30.                 {
  31.                     poleHight += 5;
  32.                     failedJumpsCounter = 0;
  33.                     if (jumpHight > targetHight)
  34.                     {
  35.                         Console.WriteLine($"Tihomir succeeded, he jumped over {targetHight}cm after {jumpsCounter} jumps.");
  36.                         break;
  37.                     }
  38.                 }
  39.                
  40.             }
  41.            
  42.            
  43.         }
  44.     }
  45. }
Add Comment
Please, Sign In to add comment