杭电acm1302
#include <stdio.h> int main() { int i;//i应定义为int double h, u, d, f, lost, temp, len;//这几个要定义为double while(scanf("%lf%lf%lf%lf", &h, &u, &d, &f)!=EOF && h) { i = 1; len = 0; lost = u * f / 100; while(i) { temp = u - (i-1) * lost; len += temp; //printf("%lf", temp); if(len>h) { //需为大于号,大于等于号为 WrongAnswer printf("success on day %d\n", i); break; } len -= d; //printf(" %lf\n", len); if(temp<0 || len<0) {//都是小于号,小于等于为 WrongAnswer printf("failure on day %d\n", i); break; } i ++; } } return 0; }