Advertisement
Guest User

Zaebal

a guest
Feb 22nd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. include <iostream>
  2. using namespace std;
  3.  
  4. int calculate(int a, int b, int h) {
  5. int currentH =0;
  6. int days=0;
  7. while(currentH < h){
  8. currentH+=a;
  9. if (currentH < h)
  10. currentH -=b;
  11. days++;
  12. }
  13. return days;
  14. }
  15.  
  16. int main(){
  17. int a, b, h;
  18. cin >> a;
  19. cin >> b;
  20. cin >> h;
  21. cout << calculate(a, b, h);
  22.  
  23. return 0;
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement