请大神帮我看看哪里错了

P1035 [NOIP2002 普及组] 级数求和

SunLakeWalk @ 2019-12-10 23:43:16

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

by JimmyF @ 2019-12-11 07:21:31

@Liu20190401126

我也看不出看惹qwq

还是换种写法吧

My AC Code:

#include<iostream>
#include<cstdio>
using namespace std;
int n,g;
double h;
int main()
{
    cin>>n;
    do
    {
        g++;
        h+=(double)(1.00/g);
    }while(h<=n);
    cout<<g;
    return 0;
}

蒟蒻求关注qwq


by ercao @ 2019-12-26 21:56:26

scanf(); 不能加换行符


|