Habsburg

zadnji

Apr 6th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N = 0;
  6. cout << "Upisite N :D \n";
  7. cin >> N;
  8.  
  9. float pi = 0;
  10. float multi = 1;
  11.  
  12. for(int i = 0; i < N ; ++i, multi += 2)
  13. i % 2 == 0 ? pi += (1/multi) : pi -= (1/multi);
  14.  
  15. pi *= 4;
  16. cout << pi;
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment