Advertisement
powerunlimited

Untitled

Oct 25th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     double pi=0;
  8.     int i=0;
  9.  
  10.     for(i=1;i<100000;++i){
  11.         double a=(2*i-1);
  12.         if(i%2==0)
  13.         {a=-a;}
  14.         a=1/a;
  15.         pi=pi+a;
  16.     }
  17.     pi=pi*4;
  18.     cout<<pi<<endl;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement