Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int n;
  10. float suma=0, wyraz=0;
  11.  
  12. cout << "Z ilu wyrazow sklada sie ten ciag?\n";
  13. cin >> n;
  14.  
  15. for (int i=1; i<=n; i++)
  16. {
  17. wyraz+=1/float(i);
  18. suma+=wyraz;
  19. cout << "Wyraz " << i << ")" << wyraz << "\n\n";
  20. }
  21.  
  22. cout << "Suma " << n << " wyrazow ciagu harmonicznego wynosi: " << suma << "\n\n\n";
  23.  
  24.  
  25. system("Pause");
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement