本题是道模拟题,又错了好几次,真太不细心了!你聪明的,能先去做做zju 1710 The Snail吗?若你已经AC了,请来告诉我下面的程序错在哪里,谢谢!
#include <iostream> usingnamespace std; int h,u,d,f; bool flag; int climb() ...{ int i=1; double s=0,t=u,deta=t*f/100; while(true) ...{ s+=t; if (s>h) ...{ flag=true; break; } s-=d; if (s<0) ...{ flag=false; break; } i++; t-=deta; } return i; } bool run() ...{ cin>>h>>u>>d>>f; if (h==0) returnfalse; int n=climb(); if (flag==true) cout <<"success on day "<< n << endl; else cout <<"failure on day "<< n << endl; returntrue; } int main() ...{ while(run()); return0; }