基础题型重温—青蛙爬井
#include <stdio.h>
int main() {
int high, up, down,days;
scanf("%d %d %d", &high, &up, &down);
int height = 0;
for(days=1;;days++){
height += up;
if(height>=high){
break;
}
height -= down;
}
printf("%d\n", days);
return 0;
}
#include <stdio.h>
int main() {
int high, up, down,days;
scanf("%d %d %d", &high, &up, &down);
int height = 0;
for(days=1;;days++){
height += up;
if(height>=high){
break;
}
height -= down;
}
printf("%d\n", days);
return 0;
}
相关推荐