一道C语言题,计算1 + 1/1!+1/2!+1/3!+...+1/n!.帮忙改下程序#include #include int main(void){int i = 1; double p = 1,fac = 0;do{ p = p * i;fac = fac + 1 / p;i++;} while ((1 / fac) > 0.00001);printf("e = %lf",fac + 1);return 0;}

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 21:21:31
一道C语言题,计算1+1/1!+1/2!+1/3!+...+1/n!.帮忙改下程序#include#includeintmain(void){inti=1;doublep=1,fac=0;do{p=p

一道C语言题,计算1 + 1/1!+1/2!+1/3!+...+1/n!.帮忙改下程序#include #include int main(void){int i = 1; double p = 1,fac = 0;do{ p = p * i;fac = fac + 1 / p;i++;} while ((1 / fac) > 0.00001);printf("e = %lf",fac + 1);return 0;}
一道C语言题,计算1 + 1/1!+1/2!+1/3!+...+1/n!.帮忙改下程序
#include
#include
int main(void)
{
int i = 1;
double p = 1,fac = 0;
do
{
p = p * i;
fac = fac + 1 / p;
i++;
} while ((1 / fac) > 0.00001);
printf("e = %lf",fac + 1);
return 0;
}

一道C语言题,计算1 + 1/1!+1/2!+1/3!+...+1/n!.帮忙改下程序#include #include int main(void){int i = 1; double p = 1,fac = 0;do{ p = p * i;fac = fac + 1 / p;i++;} while ((1 / fac) > 0.00001);printf("e = %lf",fac + 1);return 0;}
#include
#include
int main(void)
{
int i = 1;
double p = 1,fac = 0;
do
{
p = p * i;
fac = fac + 1 / p;
i++;
} while ((1 / p) > 0.00001); //注意这里
printf("e = %lf",fac + 1);
return 0;
}