大佬们看看哪儿错了

P1035 [NOIP2002 普及组] 级数求和

xqf234543 @ 2017-10-01 12:50:42

#include<iostream>
using namespace std;
int main()
{
    int k,a=0;
    double n,sn=0;
    cin>>k;
    if(k>=1&&k<=15){
    while(sn<=k){
    a++;
    n=1.0/a;
    sn=n+sn; 
    }
}
    cout<<a;
}

by Luv_Letter @ 2017-10-01 21:22:26

a从几开始?


|