Advertisement
Caneq

lb2.4.8

Oct 29th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     setlocale(LC_ALL, "rus");
  8.     double x, e = 1e-6, sum;
  9.     cout << "Введите x (0;1]" << endl;
  10.     cin >> x;
  11.     if (x <= 0 || x > 1) {
  12.         cout << "x не принадлежит (0;1]" << endl;
  13.         return 0;
  14.     }
  15.     double l = -x*x*x*x / 64; //первое слагаемое
  16.     sum = l;
  17.     int k = 1;
  18.     while (fabs(l) >= e) {
  19.         l *= -x*x / (4 * (k + 2)*(k + 2));
  20.         sum += l;
  21.         k++;
  22.     }
  23.     cout << "sum = " << sum << endl;
  24.     cout << "Количество слагаемых " << k << endl;
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement