有C语言的题解吗?

P1035 [NOIP2002 普及组] 级数求和

氢气球 @ 2017-03-13 22:20:03

#include<stdio.h>
int main()
{int k,i;
 float Sn=0;
 scanf("%d",k);
 for(i=1;Sn<k;k++)
 Sn=1./i+Sn;
 Sn=1./(i+1)+Sn;
 printf("%d\n",i+1);
 return 0;
}

by 小小梦 @ 2017-03-14 01:47:55

for(i=1;Sn<k;i++)这句不对啊


by Endure @ 2017-03-14 17:19:32

你scanf的&呢


by BanditBrook @ 2017-03-16 20:09:32

#include<stdio.h>
int main()
{
    double n,k,s=0;
    scanf("%lf",&k);
    for(n=1;s<=k;n++)
 {
    s=1/n+s;
    if (s>k)
    {
    printf("%.0f",n);
    }
 }
    return 0;
}

by 元夕 @ 2017-03-18 22:26:44

其实我就是他http://baidu.com/


by S0CRiA @ 2021-07-07 20:04:07

int kaogu=0;

++ kaogu;

printf("%d ",kaogu);

1


by S0CRiA @ 2021-07-08 12:27:25

++ kaogu;

printf("%d ",kaogu);

1 2


by S0CRiA @ 2021-07-10 17:08:36

++ kaogu;

printf("%d ",kaogu);

1 2 3


|