Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int jumpTarget, jump;
- cin >> jumpTarget;
- int startJump = jumpTarget - 30;
- int counter = 0;
- int fall = 0;
- while (fall != 3 && startJump <= jumpTarget)
- {
- cin >> jump;
- if (jump > startJump) {
- startJump += 5;
- fall = 0;
- }
- else {
- fall++;
- }
- counter++;
- }
- if (startJump <= jumpTarget)
- {
- cout << "Tihomir failed at " << startJump << "cm after " << counter << " jumps.\n";
- }
- else
- {
- cout << "Tihomir succeeded, he jumped over " << jumpTarget << "cm after " << counter << " jumps.\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement