- C++
1/j0ub
- 2024-2-24 20:35:32 @
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a=1;
double pi=0,b=1;
for(int i=1;b>=0.000001;i=i+2)
{
b=1.0/i;
pi=pi+4*a*b;
a=(-1)*a;
}
printf("%.6f",pi);
return 0;
}
0 comments
No comments so far...