Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- double h,u,d,f,p,i,t;
- while(1){
- scanf("%lf %lf %lf %lf",&h,&u,&d,&f);
- if(h==0)
- break;
- p=u*(f/100);
- i=0;
- t=0;
- while(1){
- i=i+1;
- t=t+u;
- u=u-p;
- if(u<0)
- u=0;
- if(t>h){
- printf("success on day %.0lf\n",i);
- break;
- }
- t=t-d;
- if(t<0){
- printf("failure on day %.0lf\n",i);
- break;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement