Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- double a, s;
- int k;
- do {
- cout << "Введите вещественное положительное число A = ";
- cin >> a;
- } while( a < 1.0);
- s = 0.0;
- k = 0;
- while (s < a) {
- k++;
- s = s + (1.0 / k);
- }
- s = s - (1.0 / k);
- k = k - 1;
- cout << "K = " << k << " Сумма = " << fixed << s << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment