作业帮 > 综合 > 作业

编写c++源程序计算e=1+1/1!+1/2!+1/3!+.+1/n!+.的近似值,要求误差小于0.0000001

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/29 04:46:48
编写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