2025-03-06 22:46:33 +08:00

22 lines
413 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------
编程计算求e近似值 用for语句求前50项之和。
e=0+1+1/1+1/1/2+1/1/2/3...
-------------------------------------------------------*/
#include <stdio.h>
main()
{
int i;
double t,e;
t=1.0;
e=0;
for(i=1;i<=50;i++)
{
/**********Program**********/
e += t;
t /= i;
/********** End **********/
}
printf("前50项之和为%f\n",e);
}