//计算q=1+1/1!+1/2!...当1/n!<1e-7停止
#include<iostream>
using namespace std;
int main()
{
double q = 1.0,u=1.0;
int n = 1;
while(u >=1.0e-7)
{
u = u / n;
n++;
q = q + u;
}
cout <<"q为" << q;
system("pause");
}
//计算q=1+1/1!+1/2!...当1/n!<1e-7停止
#include<iostream>
using namespace std;
int main()
{
double q = 1.0,u=1.0;
int n = 1;
while(u >=1.0e-7)
{
u = u / n;
n++;
q = q + u;
}
cout <<"q为" << q;
system("pause");
}