7个回答
展开全部
其实就是求黎曼和。
double x, pi, sum=0.0;
int i;
long N=100000;
sum = 0.0;
step = 1./(double)N;
for (i=0; i<N; i++)
{
x = (i + .5)*step;
sum = sum + 4.0/(1.+ x*x);
}
pi = sum*step;
double x, pi, sum=0.0;
int i;
long N=100000;
sum = 0.0;
step = 1./(double)N;
for (i=0; i<N; i++)
{
x = (i + .5)*step;
sum = sum + 4.0/(1.+ x*x);
}
pi = sum*step;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2017-08-15
展开全部
其实就是求黎曼和。
double x, pi, sum=0.0;
int i;
long N=100000;
sum = 0.0;
step = 1./(double)N;
for (i=0; i<N; i++)
{
x = (i + .5)*step;
sum = sum + 4.0/(1.+ x*x);
}
pi = sum*step;
double x, pi, sum=0.0;
int i;
long N=100000;
sum = 0.0;
step = 1./(double)N;
for (i=0; i<N; i++)
{
x = (i + .5)*step;
sum = sum + 4.0/(1.+ x*x);
}
pi = sum*step;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询