1 #include<iostream> 2 #include<iomanip> 3 using namespace std; 4 int main(){ 5 double t,pai=1,son=1,mum=1; 6 int i=1; 7 cin>>t; 8 while(son/mum>=t){ 9 son*=i; 10 mum*=2*i+1; 11 pai+=son/mum; 12 i++; 13 } 14 cout<<setiosflags(ios::fixed)<<setprecision(6)<<2*pai<<endl; 15 return 0; 16 }
循环-02. 计算圆周率(15),布布扣,bubuko.com
原文地址:http://www.cnblogs.com/gnodidux/p/3820405.html