编写c++源程序计算e=1+1/1!+1/2!+1/3!+.+1/n!+.的近似值,要求误差小于0.0000001必须c++语言,任何其他语言不要

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/15 02:10:07

编写c++源程序计算e=1+1/1!+1/2!+1/3!+.+1/n!+.的近似值,要求误差小于0.0000001必须c++语言,任何其他语言不要
编写c++源程序计算e=1+1/1!+1/2!+1/3!+.+1/n!+.的近似值,要求误差小于0.0000001
必须c++语言,任何其他语言不要

编写c++源程序计算e=1+1/1!+1/2!+1/3!+.+1/n!+.的近似值,要求误差小于0.0000001必须c++语言,任何其他语言不要
#include
int f(int n);
int main()
{
double e, t = 1;
int n = 1;
while (1)
{
e = t + 1.0/f(n++);
if ( e-t < 0.0000001)
{
break;
}
t = e;
}
cout