pai的近似值求解
第三题
#include<stdio.h>
int main()
{
int n;
float i,k,x,a,pai = 1, PAI;
scanf("%d",&n);
for (i = 2; i < n; i+=2)
{
k = i*i;
x = (i - 1)*(i +1);
a= k / x;
pai = pai*a;
}
PAI =pai * 2;
printf("%f", PAI);
getchar();
getchar();
return 0;
}
算不出3.141592