#include<stdio.h>
#include<math.h>
int main( )
{
int x=1;
double pi=0.0,y=1,z=1;
while(fabs(z)>=1e-6)
{
pi=pi+z;
y=y+2;
x=-x;
z=x/y;
}
pi=pi*4;
printf("pi=%10.8f",pi);
}
C语言------圆周率
共计 0 条评论,点此发表评论