Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06.HighJump
- {
- class HighJump
- {
- static void Main(string[] args)
- {
- int height = int.Parse(Console.ReadLine());
- int startheight = height - 30;
- int numJumps = 0;
- int fail = 0;
- while (true)
- {
- int jump = int.Parse(Console.ReadLine());
- numJumps++;
- if (startheight < jump)
- {
- if (startheight >= height)
- {
- break;
- }
- startheight += 5;
- fail = 0;
- }
- else
- {
- fail++;
- }
- if (fail == 3)
- {
- break;
- }
- //else if (startheight >= height)
- //{
- // numJumps += 1;
- // break;
- //}
- }
- if (fail == 3)
- {
- Console.WriteLine($"Tihomir failed at {startheight}cm after {numJumps} jumps.");
- }
- else if (startheight >= height)
- {
- Console.WriteLine($"Tihomir succeeded, he jumped over {startheight}cm after {numJumps} jumps.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement