题目描述计算t=1+12+13++1n输入整型变量n输出t保留六位小数样例输入 复制10样例输出 复制2928968 cpp
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int n;
cin >> n;
double t = 0;
for (int i = 1; i <= n; i++) {
t += 1.0 / i;
}
cout << fixed << setprecision(6) << t << endl;
return 0;
}
原文地址: http://www.cveoy.top/t/topic/i3B1 著作权归作者所有。请勿转载和采集!