Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int n;
- float suma=0, wyraz=0;
- cout << "Z ilu wyrazow sklada sie ten ciag?\n";
- cin >> n;
- for (int i=1; i<=n; i++)
- {
- wyraz+=1/float(i);
- suma+=wyraz;
- cout << "Wyraz " << i << ")" << wyraz << "\n\n";
- }
- cout << "Suma " << n << " wyrazow ciagu harmonicznego wynosi: " << suma << "\n\n\n";
- system("Pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement