0分求助

P1035 [NOIP2002 普及组] 级数求和

siyeansh @ 2021-08-11 11:16:09

goto手写循环

#include<iostream>
#include<cstdio>
using namespace std;
int k,i=0;
double s=0.0000;
int main(){
    cin>>k;
    AABB:{
        s=s+ (1.0/i);
    }if(s<=k)goto AABB;
    printf("%d",i);
    return 0;
}

by 王瑞eggome @ 2021-08-11 11:18:28

i是整型


by 王瑞eggome @ 2021-08-11 11:23:05

i还一直是0


by siyeansh @ 2021-08-11 11:27:32

@王瑞eggome 回:哦哦,知道了,粗心(~-~)


by siyeansh @ 2021-08-11 11:27:58

多谢大佬,A了


|