/*-------------------------------------------------------
编程计算求e近似值:
用while语句求直到最后一项值小于10-5为止。
e=0+1+1/1+1/1/2+1/1/2/3...
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int i;
double t,e;
i=1;
t=1.0;
e=0;
/**********Program**********/
e=e+t;
while(t>=1e-5)
{
e=e+t;
i++;
t=t/i;
}
/********** End **********/
printf("e=%f\n",e);
}
PTA✨C语言 求e的近似值
2024-02-16 23:22:01 32 阅读