计算π的值
题目:程序:
#include <stdio.h>
#include <math.h>
void main()
{
int s ;
float n,t,pi;
t=1; pi=0; n=1.0; s=1;
while( fabs(t) > 1e-7 )
{
pi = pi + t; n = n+2; s = -s; t=s/n;
}
pi = pi*4;
printf("pi = %10.6f\n",pi);
}
运行结果:
关于计算π的值>>>>>标题要长<<<<
http://bbs.fishc.com/thread-57104-1-1.html
(出处: 鱼C论坛)
页:
[1]