【例6】计算e=1+1/1!+1/2!+1/3!+...当1/n!<1e-7停止
#include <iostream>
using namespace std;
void main()
{double e=1.0,u=1.0;//不能赋值整数,否则除法运算得不出想要的结果
int n=1;
do{
e=e+u;//求累加和
n=n+1;//计算分母中的n
u=u/n;//得到下一个加数
}while(u>=1.0e-7);
cout<<"e="<<e<<"(n="<<n<<")"<<endl;
}