早教吧作业答案频道 -->其他-->
十万火急!浙大OJ1113uCalculateeWA坐等大侠指点ProblemDescriptionAsimplemathematicalformulaforeiswherenisallowedtogotoinfinity.Thiscanactuallyyieldveryaccurateapproximationsofeusingrelativelysmallvaluesofn
题目详情
十万火急 !浙大OJ 1113 u Calculate e WA 坐等大侠指点
Problem Description
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.
Sample Output
n e
- -----------
0 1
1 2
2 2.5
3 2.666666667
4 2.708333333
这是我的代码
#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",e);
else
printf("%.9lf\n",e);
}
return 0;
}
Problem Description
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.
Sample Output
n e
- -----------
0 1
1 2
2 2.5
3 2.666666667
4 2.708333333
这是我的代码
#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",e);
else
printf("%.9lf\n",e);
}
return 0;
}
▼优质解答
答案和解析
#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);
}
//scanf("%*d");
return 0;
}
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);
}
//scanf("%*d");
return 0;
}
看了 十万火急!浙大OJ1113u...的网友还看了以下:
(P/F,r,5)=4.4518什么意思是会计计算题里面出现的. 2020-04-07 …
810=1000*(P/F,r,5)+50*(P/A,r,5)*(1+r)算r用插值法还行吗?原题 2020-04-07 …
递延年金现值公式的意思P=A*(P/A,i,n)*(P/F,i,m),这个P/A,和P/F,到底是 2020-05-15 …
A.F,H,C,D,P,A,M,Q,R,S,Y,XB.P,A,C,S,Q,D,F,X,R,H,M,Y 2020-05-26 …
如何用插值法来计算利率r?这里有一题是59(P/A,r,4)+1309(P/F,r,5)=1000 2020-07-17 …
设一组初始记录关键字序列为(Q,H,C,Y,P,A,M,S,R,D,F,X),则按字母升序的第一趟 2020-07-17 …
一道函数题二次函数f(x)=px^2+qx+r中,实数p,q,r满足p/(m+2)+q/(m+1) 2020-07-26 …
谁能帮我组个英语单词①e、n、o、p、t、w、y②e③d、t、y④b、c、f、m、p、r、t、v⑤ 2020-07-29 …
已知集合M={f(x)|f(-x)=f(x),x∈R};N={f(x)|f(-x)=-f(x),x 2020-07-30 …
如图所示,两个相同的空心金属球M和NM带-Q电荷,N不带电,旁边各放一个不带电的金属球P和R(M、N 2020-12-04 …