发代码啊要不然怎么帮你改
by yanxingyu0910 @ 2022-10-24 21:04:22
错误数据:输入:4.3
输出应为3
(~~应该是莆yuan的吧~~)
by luoyicen @ 2022-10-24 21:07:18
@[yanxingyu0910](/user/607856)
```c
#include<stdio.h>
int main()
{
int n=0,x=2,flag=1;
double s,m=2;
scanf("%lf",&s);
if(x<=2)
{
printf("%d",flag);
}
else{
while(m<s)
{
x=x*0.98;
m=m+x;
n=n+1;
}
}
printf("%d",flag);
return 0;
} //他的代码
```
by luoyicen @ 2022-10-24 21:08:21
@[Iris202212904341](/user/811399)
```c
#include<stdio.h>
int main()
{
int n=1;
double s,m=2,x=2;
scanf("%lf",&s);
while(m<s)
{
x=x*0.98;
m=m+x;
n++;
}
printf("%d",n);
return 0;
}
```
过了。x类型错了。
by with_no_signal @ 2022-10-24 21:11:46
这代码...while里面flag没用诶而且特判不return0等于有输出了一个flag建议lz按楼上的来
by yanxingyu0910 @ 2022-10-24 21:23:28
```#include<iostream>
using namespace std;
int main(void)
{
double h,a;
cin>>h;
for(double i=2.0;h>0;i*=0.98)
{
h-=i;
a++;
}
cout<<a;
return 0;
}```
by ikun_czy @ 2022-11-04 21:09:36
@[czy888](/user/817033) 你连
```c
# include <iostream>
```
都不加吗?
by wdvgyh @ 2022-11-04 22:12:42
@[wdvgyh](/user/855736)
忘复制了
by ikun_czy @ 2022-11-05 10:30:08
@[wdvgyh](/user/855736)
不可能不加
by ikun_czy @ 2022-11-05 10:30:45
上面代码没有
```
#include<iostream>
```
敬请大家谅解
by ikun_czy @ 2022-11-05 10:32:29