Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main() {
- double x, eps, sum = 0.0;
- do {
- cout << "Введите x = ";
- cin >> x;
- if (x == 0) {
- cout << "Неверное значение x\n";
- }
- } while (x == 0);
- do {
- cout << "Введите eps = ";
- cin >> eps;
- if (eps <= 0 || eps >= 1) {
- cout << "Неверное значение eps\n";
- }
- } while (eps <= 0 || eps >= 1);
- double u = 1;
- int k = 1;
- do {
- if (k == 1) {
- cout << "U0 = 0\n";
- }
- else {
- u *= (-x * x) * pow(k - 1, 3) / (pow(k, 3) * (k + 1));
- sum += u;
- cout << "U" << (k - 1) << " = " << u << endl;
- }
- k++;
- } while (abs(u) > eps);
- cout << "Сумма ряда = " << sum << "; Количество элементов = " << (k - 1) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement