Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "RUSSIAN");
- const int MaxIterationCount = 500;
- double x, eps; int n;
- cout << "Введите аргумент: ";
- cin >> x;
- cout << " " << endl;
- cout << endl << "Введите точность: ";
- cin >> eps;
- cout << endl;
- bool done = true;
- double y = x, ch = x;
- for (n = 1; fabs(ch) > eps; n++)
- {
- ch *= x*x / ((2 * n + 1)*(2 * n + 2));
- y += ch;
- if (n > MaxIterationCount) {
- done = false; break;
- }
- }
- cout << " " << endl;
- if (done) cout << "Значение функции: " << y << endl;
- else cout << "Ошибка: ряд расходится!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement