求C语言编程,e=1+1/1!+1/2!+1/3!+...+1/n!,精确度1e-6
求C语言编程,e=1+1/1!+1/2!+1/3!+...+1/n!,精确度1e-6
日期:2019-05-20 14:24:37 人气:3
#include
using namespace std;
int main()
{
int i=1;
double e=1.0,d=1.0;
while(d>=1e-6)
{
d=d/i;
e+=d;
i++;
}
cout<<"e的值为:"<<e<<endl;
return 0;
}