Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <iomanip>
- int main()
- {
- system("chcp 1251 > nul");
- double eps, sum, k;
- bool isNotCorrect;
- sum = 0;
- k = 1;
- std::cout << "Введите EPS: ";
- do {
- std::cin >> eps;
- if (std::cin.fail() || (eps > 1) || !(eps > 0)) {
- isNotCorrect = true;
- std::cout << "Введите действительное число в промежутке (0;1]" << '\n';
- std::cin.clear();
- while (std::cin.get() != '\n');
- }
- else {
- isNotCorrect = false;
- }
- } while (isNotCorrect);
- while (!(k < eps)) {
- sum = sum + k;
- k = k / 2;
- };
- std::cout << std::setprecision(15);
- std::cout << "Сумма членов ряда: " << sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement