Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06._High_Jump
- {
- class Program
- {
- static void Main(string[] args)
- {
- int targetHight = int.Parse(Console.ReadLine());
- int stepHight = (targetHight - 30);
- int level = 0;
- int temp = int.MinValue;
- int atemptCounter = 0;
- int atemptCounterTemp = 0;
- while (temp < targetHight)
- {
- int currentHight = stepHight + level;
- int atempt = int.Parse(Console.ReadLine());
- if (currentHight >= atempt)
- {
- atemptCounterTemp++;
- }
- if (currentHight < atempt && atemptCounter >= 3 )
- {
- atemptCounterTemp--;
- }
- atemptCounter++;
- temp = atempt;
- if (temp <= currentHight && atemptCounterTemp >= 3)
- {
- Console.WriteLine($"Tihomir failed at {atempt}cm after {atemptCounter} jumps.");
- return;
- }
- else if ( temp > currentHight)
- {
- level += 5;
- continue; ;
- }
- }
- if (temp > targetHight)
- {
- Console.WriteLine($"Tihomir succeeded, he jumped over {targetHight}cm after {atemptCounter} jumps.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement