zhs3202669494 @ 2020-01-27 11:50:02
#include <stdio.h>
#include <stdlib.h>
int main()
{
float S=0;
int k,n;
scanf("%d",&k);
for(n=1;;n++)
{
S+=1.0/n;
if(S>k)
{
break;
}
}
printf("%d",n);
return 0;
}
by ztxtjz @ 2020-01-27 11:53:02
float改成double就可以了
by ztxtjz @ 2020-01-27 11:56:11
@zhs3202669494
by zhs3202669494 @ 2020-01-27 12:04:01
@ztxtjz 谢谢,做对了。但是为什么要改成double呢?
by critnos @ 2020-01-27 12:06:27
@zhs3202669494 精度问题
by zhs3202669494 @ 2020-01-27 12:33:01
@26535 懂了,谢谢
by 故魇 @ 2020-02-03 12:52:29
@ztxtjz 这些题真的是#¥……&%……*&……&¥¥%……%¥……&%…………&……@#@@!¥%¥&(
by ztxtjz @ 2020-02-03 19:45:53
@故魇 ???Orz