Asercn @ 2019-12-14 14:42:37
#include <stdio.h>
//¼ÆËãSn
double Sn(double n);
int main()
{
int k;
scanf("%d",&k);
int b=k;
while(1)
{
if((Sn(b)) <= k)
{
b++;
//printf("%d",b);
}
else
{
printf("%d",b);
return 0;
}
}
}
double Sn(double n)
{
double sum;
while(n>0)
{
sum += (1/n);
n--;
}
return sum;
}
by hht2005 @ 2019-12-14 14:49:20
输出都不一样当然不会影响结果。
by hht2005 @ 2019-12-14 14:49:27
@as200cxh
by Asercn @ 2019-12-14 15:36:53
@hht2005 我是说最后b的结果
by hht2005 @ 2019-12-14 16:10:07
@as200cxh 最后b不会变,但你的输出不对了啊