further @ 2019-10-29 15:43:17
#include<stdio.h>
int main()
{
int k,n;
float s,a;
scanf("%d",&k);
s=0;
a=0;
for(n=1;s<=k;n=n+1){
a=1.0/n;
s=s+a;
}
n=n-1;
printf("%d",n);
return 0;
}
by 茶道先辈 @ 2019-10-29 15:47:48
@further 大佬,开double
by 茶道先辈 @ 2019-10-29 15:50:06
被我威猛的外表吓跑了?
by further @ 2019-10-29 15:54:54
@黄秉你 为什么float不行啊
by further @ 2019-10-29 15:56:15
@黄秉你 大佬nb,还真对了
by 茶道先辈 @ 2019-10-29 15:58:00
@further 因为float精度不够
by 茶道先辈 @ 2019-10-29 15:58:13
刚没看到啊
by further @ 2019-10-29 15:59:32
@黄秉你 好吧,按道理不是float会自动转化为double型的吗
by 茶道先辈 @ 2019-10-29 16:01:11
@further ?????!!!!!!!!!!!
by 茶道先辈 @ 2019-10-29 16:03:13
我被您渊博的知识吓跑了
by further @ 2019-10-29 16:03:16
@黄秉你 难道不是吗,我们老师说的啊