tutou007 @ 2019-11-01 20:24:37
#include<stdio.h>
int main(void)
{
int k;
float i,s=0;
scanf("%d",&k);
for(i=1;s<=k;i++)
{
s = s+1/i;
}
i=i-1;
printf("%d",(int)i);
return 0;
}
by exit0 @ 2019-11-01 20:41:42
while循环多好
by tutou007 @ 2019-11-03 16:28:02
@萌新南凉北暖 尝试了一下while还是只有六十分,怎么办。
by exit0 @ 2019-11-03 17:47:17
@tutou007 发一下你代码
by tutou007 @ 2019-11-03 20:50:55
@萌新南凉北暖 ```c
int main(void) { int k; double i=1,s=0; scanf("%d",&k); while(s<=k) { s=s+1/i; i++; } i=i-1; printf("%d",(int)i); return 0; } 问题解决了,把folat换成double就好了