Advertisement
avram0ff

High Jump

Apr 7th, 2020
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 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 desiredHeight = int.Parse(Console.ReadLine());
  10.  
  11.             int totalJumps = 0;
  12.             int failedJumps = 0;
  13.  
  14.             int currentHeight = desiredHeight - 30;
  15.  
  16.             while (currentHeight <= desiredHeight)
  17.             {
  18.                 for (int i = 0; i < 3; i++)
  19.                 {
  20.                     int jumpHeight = int.Parse(Console.ReadLine());
  21.  
  22.                     totalJumps++;
  23.  
  24.                     if (jumpHeight > currentHeight)
  25.                     {
  26.                         currentHeight += 5;
  27.                         break;
  28.                     }
  29.  
  30.                     if (i == 2)
  31.                     {
  32.                         Console.WriteLine($"Tihomir failed at {currentHeight}cm after {totalJumps} jumps.");
  33.                         return;
  34.                     }
  35.                 }
  36.             }
  37.  
  38.             Console.WriteLine($"Tihomir succeeded, he jumped over {desiredHeight}cm after {totalJumps} jumps.");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement