Files
python/RuMenJingDian/Others/L_2_3.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

21 lines
520 B
C++

#include <bits/stdc++.h>
using namespace std;
int main() {
//读入输出优化的强迫症
ios::sync_with_stdio(false);
double sum = 0;
for (int i = 0;; i++) {
double term = 1.0 / (i * 2 + 1);
if (i % 2 == 0)sum += term;
else sum -= term;
if (term < 1e-6) break; //注意科学记数法
}
printf("%.6f\n", sum); //保留六位小数
//本程序耗时
printf("Time used = %.2f\n", (double) clock() / CLOCKS_PER_SEC);
return 0;
}