Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace P06.HighJump
- {
- class HighJump
- {
- static void Main(string[] args)
- {
- const int INITIAL_HIGH_LESS_THAN_GOAL_IN_CM = 30;
- const int INCREASE_HIGH_FOR_A_SUCCESSFUL_JUMP_IN_CM = 5;
- const int LIMIT_TIMES_FOR_UNSUCCESSFUL_JUMPS = 3;
- int goal = int.Parse(Console.ReadLine());
- int currentJump = int.Parse(Console.ReadLine());
- int start = goal - INITIAL_HIGH_LESS_THAN_GOAL_IN_CM;
- int countOfTotalJumps = 0;
- int countOfUnsuccessfulJumps = 0;
- while (start <= goal)
- {
- while (currentJump <= start)
- {
- countOfTotalJumps++;
- countOfUnsuccessfulJumps++;
- if (countOfUnsuccessfulJumps == LIMIT_TIMES_FOR_UNSUCCESSFUL_JUMPS)
- {
- Console.WriteLine($"Tihomir failed at {start}cm after {countOfTotalJumps} jumps.");
- return;
- }
- currentJump = int.Parse(Console.ReadLine());
- }
- if (currentJump > goal)
- {
- break;
- }
- countOfTotalJumps++;
- countOfUnsuccessfulJumps = 0;
- start += INCREASE_HIGH_FOR_A_SUCCESSFUL_JUMP_IN_CM;
- currentJump = int.Parse(Console.ReadLine());
- }
- countOfTotalJumps++;
- Console.WriteLine($"Tihomir succeeded, he jumped over {goal}cm after {countOfTotalJumps} jumps.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment