作业帮 > 英语 > 作业

ACM的浙大的第1113题,

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:英语作业 时间:2024/06/04 13:38:40
ACM的浙大的第1113题,
u Calculate e Time Limit:2 Seconds Memory Limit:65536 KB Background A simple mathematical formula for e is where n is allowed to go to infinity.This can actually yield very accurate approximations of e using relatively small values of n.Output Output the approximations of e generated by the above formula for the values of n from 0 to 9.The beginning of your output should appear similar to that shown below.
Example Output
n e
- -----------
0 1
1 2
2 2.5
3 2.666666667
4 2.
翻译:你计算e 期限:2秒内存限制:65536 KB 背景 一个简单的数学公式来e 这里n是允许趋于无穷大.这实际上可以产生非常精确的近似的e n值用相对较小.输出 输出近似的e产生上述公式为n值从0到9.一开始你的输出应类似于下面所示.
示例 输出
n e
- - - - - - - - - - - - - - -
0 1
1 2
2 2.5
3 2.666666667
4 2.708333333
忘了说了,是用C语言编写的!
ACM的浙大的第1113题,
#include
int main()
{
int n,b;
double e=2.00,a=1.00;
printf("n e\n");
printf("- -----------\n");
for(n=0;n=2)
{
a=a/n;
e=e+a;
}
if(n==2)
printf("%.1lf\n",e);
else
printf("%.9lf\n",e);
}
return 0;
}