Advertisement
otot957

Untitled

Aug 13th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include<array>
  3. #include <bits/stdc++.h>
  4. #include<string>
  5. using namespace std;
  6. int main ()
  7.  
  8.  
  9.  
  10. {
  11.     double h=0,u=0,d=0,f=0,k=1;
  12.     float c,m=0;
  13.     cin>>h>>u>>d>>f;
  14.     while(h!=0){
  15.         c=u*(f/100);
  16.         m=0;
  17.         k=0;
  18.         while(m>=0){
  19.             k++;
  20.             m+=u;
  21.             if(m<=h) {
  22.                    
  23.                     m-=d;
  24.             }
  25.             else {
  26.                 cout<<"success on day "<<k<<endl;
  27.                 break;
  28.             }
  29.            if(u>0) u-=c;
  30.             else u=0;
  31.  
  32.  
  33.         }
  34.         if(m<0) cout<<"failure on day "<<k<<endl;
  35.         cin>>h>>u>>d>>f;
  36.     }
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement