#include
using namespace std;
void ans(int n)
{
cout<double pi = 1.0;
for(int i = 1; i <= n; i++)
{
double x = (2.0 * i) / (2.0 * i - 1);
double y = (2.0 * i) / (2.0 * i + 1);
double z = x * 银侍y;
pi *= z;
}
cout<<2.0 * pi<<州扒endl;
}
int main()
{
册搏昌 ans(10);
ans(100);
ans(1000);
return 0;
}
#include
double fun(double n)
{
return 2*n*2*n/((2*n-1) * (2*n+1));
}
int main(void)
{
double sum= 2;
for (int n= 1; n<= 1000; n++)
{
sum*= fun(n);
if(n==10)
cout<<"n= 10时,\tπ= "<if(n==100)
cout<<"n= 100时,\tπ= "<<行烂sum<if(n==1000)
cout<<档岩漏"n= 1000时,\tπ= "<}
return 0;
}
c可以吗?