Advertisement
stbodurov

06. High Jump

Mar 17th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace OfficialExam1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int wantedHeight = int.Parse(Console.ReadLine());
  14.  
  15.  
  16.             int lathHeight = wantedHeight - 30;
  17.             int jumpCounter = 0;
  18.             int currentTry = 0;
  19.             int jumpHeight = 0;
  20.  
  21.             while (true)
  22.             {
  23.                 for (currentTry = 1; currentTry <= 3; currentTry++)
  24.                 {
  25.                     jumpHeight = int.Parse(Console.ReadLine());
  26.                     jumpCounter++;
  27.                     if (jumpHeight > wantedHeight)
  28.                     {
  29.                         Console.WriteLine($"Tihomir succeeded, he jumped over {wantedHeight}cm after {jumpCounter} jumps.");
  30.                         return;
  31.                     }
  32.                     if (jumpHeight > lathHeight)
  33.                     {
  34.                         lathHeight += 5;
  35.                         break;
  36.                     }
  37.                      
  38.                    
  39.                 }
  40.                 if (currentTry == 4)
  41.                 {
  42.                     Console.WriteLine($"Tihomir failed at {lathHeight}cm after {jumpCounter} jumps.");
  43.                     return;
  44.                 }
  45.  
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement