Advertisement
jkonova

Untitled

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