c++我是想不出来了ToT

P1035 [NOIP2002 普及组] 级数求和

114514aaaazx @ 2024-05-22 22:08:13

#include<bits/stdc++.h>
using namespace std;
int main(){
double n,k=0,t=0;
cin>>k;
for(n=1;t>k;n++)t=1/n+t;
n=t;
cout<<n;
} 

by ZhangXuKun @ 2024-05-22 22:22:18

#include<bits/stdc++.h>
using namespace std;
int main(){
    double n, k = 0, t = 0;
    cin >> k;
    for (n = 1; t >= k; n++) {
        t = 1 / n + t;
    }
    n = t;
    cout << n;
}

by 114514aaaazx @ 2024-05-22 22:26:10

我真服了 devc++的编译器是错误的,在洛谷又对了 【生气】


|