Advertisement
naskedvi

S1 - zad.10

Mar 2nd, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. int n;
  6. float x;
  7. std:: cout << "Unesite x: ";
  8. std:: cin >> x;
  9. std:: cout << "Unesite n: ";
  10. std:: cin >> n;
  11.  
  12. float s1=0, s2=0;
  13. for (int i=1; i<=n; i++)
  14. {
  15. if(i%2==0)
  16. {
  17. s1+=1/(x*(x+i));
  18. }
  19. else
  20. s2+=1/(x*(x+i));
  21. }
  22.  
  23. std:: cout << "Suma je: " << s1-s2;
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement