Advertisement
wigllytest

Untitled

Aug 27th, 2020
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int goalHeight; cin >> goalHeight;
  9.  
  10. int startHeight = goalHeight - 30;
  11. int countJumps = 0;
  12. bool flag = false;
  13.  
  14. while (startHeight <= goalHeight)
  15. {
  16.  
  17. for (int i = 0; i < 3; i++)
  18. {
  19. int jumpedHeight;
  20. cin >> jumpedHeight;
  21. countJumps++;
  22.  
  23. if (jumpedHeight > startHeight)
  24. {
  25. startHeight += 5;
  26. break;
  27. }
  28.  
  29. if (i == 2)
  30. {
  31. cout << "Tihomir failed at " << jumpedHeight << "cm after " << countJumps << " jumps.";
  32. flag = true;
  33. }
  34. }
  35.  
  36. if (flag) break;
  37. }
  38.  
  39. if (!flag)
  40. {
  41. cout << "Tihomir succeeded, he jumped over " << goalHeight << "cm after " << countJumps << " jumps.";
  42. }
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement