Guest User

High Jump

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