早教吧作业答案频道 -->其他-->
十万火急!浙大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...的网友还看了以下:
选出划线部分读音不同的选项1.t(i)mev(i)olinfavor(i)tek(i)nd2.sh 2020-05-14 …
u,i,n,c,o,s可以拼成什么单词?还有,o,s,l,h,u,d还有,t,p.s.n.e.r, 2020-05-23 …
把下列各组字母含有相同读音的一组选出来.1.A.t,vB.t,aC.l,tD.b,n()2.A.r 2020-06-08 …
A.根据释义,拼写单词.1.costingalotofmoneyx,p,s,i,e,e,e,n,v 2020-06-10 …
用以下英文宇母填在上a,a,a,a,a,a,b,e,e,d,e,e,e,e,e,e,f,g,g用以 2020-06-24 …
1.r,h,n,y,e2.c,e,s,c,n,i,e3.p,1,a,p,e4.r,a,t5.p,o 2020-07-09 …
写单词,这些单词打乱顺序了!:1.d,f,e,n,i,f,e,r,t,()2.g,h,o,e,t, 2020-07-26 …
高压输电的原理:Q=I平方×R×t和P=U×I,当P和t一定时减小U才能减小I,从而减小Q,即线损电 2020-11-21 …
9个字母,已知有:c,o,t,l,n,u,o无顺序.是什么单词啊.急还有1个i,还有e,总共是:c, 2020-12-05 …
把给的字母中多余的一个字母丢掉,再把正确的单词拼出来(1)s,t,e,b,a,k,e(2)r,t,a 2020-12-14 …