c++计算t=1+1/2+1/3+...+1/n

#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	double t = 0;
	for (int i = 1; i <= n; i++)
	{
		double m = 1.0/ i;
		t = t + m;
	}
	cout << fixed<< setprecision(6) << t << endl;
	return 0;
}