帮帮孩子吧,为什么wr

P1035 [NOIP2002 普及组] 级数求和

zz1849896763 @ 2023-10-19 11:47:52

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

by IkeveLand @ 2023-10-19 12:00:15

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

by zz1849896763 @ 2023-10-21 09:07:18

@happysheep 感谢 qaq


|