Advertisement
BowserFlash13

da

May 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9.     int n;
  10.     double sum = 1.0000;
  11.  
  12.     cout << "Broj? ";
  13.     cin >> n;
  14.     cout << endl;
  15.     while(n>1) {
  16.         if(n%2==0){
  17.             sum -= 1 / (n*n);
  18.             cout << "#Da# ";
  19.         }
  20.         else {
  21.             sum += 1 / (n*n);
  22.             cout << "#Ne# ";
  23.         }
  24.  
  25.         n--;
  26.     }
  27.     cout << setprecision(3) << sum;
  28.  
  29.     system("pause");
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement