Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int goalHeight; cin >> goalHeight;
- int startHeight = goalHeight - 30;
- int countJumps = 0;
- bool flag = false;
- while (startHeight <= goalHeight)
- {
- for (int i = 0; i < 3; i++)
- {
- int jumpedHeight;
- cin >> jumpedHeight;
- countJumps++;
- if (jumpedHeight > startHeight)
- {
- startHeight += 5;
- break;
- }
- if (i == 2)
- {
- cout << "Tihomir failed at " << jumpedHeight << "cm after " << countJumps << " jumps.";
- flag = true;
- }
- }
- if (flag) break;
- }
- if (!flag)
- {
- cout << "Tihomir succeeded, he jumped over " << goalHeight << "cm after " << countJumps << " jumps.";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement