#include <math.h>
#include <stdio.h>
void main ()
{
int s;
float n,t,pi;
s=1,pi=0,n=t=1.0;
do
{
pi+=t;
n+=2;
s=-s;
t=s/n;
}while(fabs(t)>1e-5);
pi*=4;
printf("pi=%.9f\n",pi);
}
c语言 利用分式前n项和求圆周率
猜你喜欢
转载自blog.csdn.net/ling_cmd/article/details/78296713
今日推荐
周排行