Advertisement
Valantina

HighJump/EX

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