@[zxhiding](/user/814481)
```cpp
#include<stdio.h>
int main() {
float x;
int d = 0;
scanf("%f", &x);
for (float i = 2, c = 0; c <= x; c += i, i=i*98.0/100,d++);
printf("%d", d);
return 0;
}
```
by ReTF @ 2022-10-07 13:01:23
e
by jerryee @ 2022-10-15 22:10:25
```cpp
#include <iostream>
using namespace std;
int main(){
float metre,step=2;
int cnt =0;
scanf("%f",&metre);
while (metre >0) {
metre -= step;
step*=0.98;
cnt++;
}
printf("%d",cnt);
}
```
by jerryee @ 2022-10-15 22:18:04
不要用for循环,用while,一行代码换成多行,既美观又明了,其实我也不大懂C语言。
#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
float s,q=0,m=2,sum=0;
cin>>s;
while(s>q)
{
q=q+m;
m=m*98/100;
sum=sum+1;
}
cout<<sum;
return 0;
}
```
用C++改的
by Zhengzhiyuan_1223 @ 2022-10-15 22:38:47