Advertisement
Zaksofon

Untitled

Feb 28th, 2020
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06._High_Jump
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.  
  9.         {
  10.             int targetHight = int.Parse(Console.ReadLine());
  11.             int stepHight = (targetHight - 30);
  12.             int level = 0;
  13.             int temp = int.MinValue;
  14.             int atemptCounter = 0;
  15.             int atemptCounterTemp = 0;
  16.             while (temp < targetHight)
  17.             {
  18.                 int currentHight = stepHight + level;
  19.                 int atempt = int.Parse(Console.ReadLine());
  20.                 if (currentHight >= atempt)
  21.                 {
  22.                     atemptCounterTemp++;
  23.                 }
  24.                 if (currentHight < atempt && atemptCounter >= 3 )
  25.                 {
  26.                     atemptCounterTemp--;
  27.                 }
  28.                 atemptCounter++;
  29.                 temp = atempt;
  30.                 if (temp <= currentHight && atemptCounterTemp >= 3)
  31.                 {
  32.                     Console.WriteLine($"Tihomir failed at {atempt}cm after {atemptCounter} jumps.");
  33.                     return;
  34.                 }
  35.                 else if ( temp > currentHight)
  36.                 {
  37.                     level += 5;
  38.                     continue; ;
  39.                 }
  40.             }
  41.             if (temp > targetHight)
  42.             {
  43.                 Console.WriteLine($"Tihomir succeeded, he jumped over {targetHight}cm after {atemptCounter} jumps.");
  44.                
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement