Advertisement
Guest User

Untitled

a guest
Mar 31st, 2022
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 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 _06.High_Jump
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int intendedHeight = int.Parse(Console.ReadLine());
  14.  
  15.             int unsuccesCounter = 0;
  16.             int jumpsCounter = 0;
  17.             int startJumpHeiht = intendedHeight - 30;
  18.            
  19.             while (startJumpHeiht <= intendedHeight)
  20.             {
  21.                 int jumpHeight = int.Parse(Console.ReadLine());
  22.                 jumpsCounter++;
  23.                
  24.                 if (jumpHeight > startJumpHeiht)
  25.                 {
  26.                     startJumpHeiht += 5;
  27.                     unsuccesCounter = 0;
  28.                     if (startJumpHeiht > intendedHeight)
  29.                     {
  30.                         Console.WriteLine($"Tihomir succeeded, he jumped over {intendedHeight}cm after {jumpsCounter} jumps.");
  31.                         return;
  32.                     }
  33.                 }
  34.                 else
  35.                 {
  36.                     unsuccesCounter++;
  37.                     if (unsuccesCounter == 3)
  38.                     {
  39.                         Console.WriteLine($"Tihomir failed at {jumpHeight}cm after {jumpsCounter} jumps.");
  40.                         return;
  41.                     }
  42.                 }
  43.             }
  44.         }
  45.     }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement