Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main() {
- int n;
- double sum = 1.0000;
- cout << "Broj? ";
- cin >> n;
- cout << endl;
- while(n>1) {
- if(n%2==0){
- sum -= 1 / (n*n);
- cout << "#Da# ";
- }
- else {
- sum += 1 / (n*n);
- cout << "#Ne# ";
- }
- n--;
- }
- cout << setprecision(3) << sum;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement