/*-------------------------------------------------------
编程计算π的近似值(直到最后一项的绝对值小于10-5为止,使用while):  
-------------------------------------------------------*/
#include <stdio.h>
#include <math.h>
#define N 1e-5
main()
{
	int i,f;
	double t,s;
	f=1;
	s=0;
	i=1;
	t=1.0;
/**********Program**********/
	while(fabs(t/i)>N){
		s+=t/i*f;//计算该项的值
		f*=-1;//翻转符号
		i+=2;
	}




/**********  End  **********/	
	s=s*4 ;
	printf("圆周率的近似值为:%f\n",s);
}