根据以下表达式计算π的近似值。要求误差不大于0.00001。
![在这里插入图片描述](https://img-blog.csdnimg.cn/20190719001154566.png)
输出格式:
直接输出保留6位小数的实型结果,没有其它任何附加字符。 输出样例: 3.141566)
输出样例:
3.141566
#include "stdio.h"
void main()
{
float pi=1,t=1,k=3;
int i;
for(i=1;i<1000;i++)
{
t*=i/k;
pi=pi+t;
k=k+2;
if(t<0.00002)break;
}
printf("%f",2*pi);
exit(0);
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019072016150640.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTEwOTAxMDQ=,size_16,color_FFFFFF,t_70)