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

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