Advertisement
r1411

Untitled

May 1st, 2021
783
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #define Я_РУССКИЙ "Russian"
  2. #include <fstream>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. void main() {
  7.     setlocale(LC_ALL, Я_РУССКИЙ);
  8.  
  9.     int a = 1, n = 0, f = 0;
  10.     long double b = 1, c = 1;
  11.     double x, e, result = 0, prevResult = 0;
  12.     cin >> x >> e;
  13.     do {
  14.         prevResult = result;
  15.         cout << "n= " << n << "\t a = " << a << "\t b= " << b << "\t c= " << c << "\t [[a/b * c = " << (double) a / b * c << "]]" << endl;
  16.         result += (double) a / b * c;
  17.        
  18.         n = n + 1; f += 2;
  19.         a = a * -1;
  20.         b = b * (f - 1) * f;
  21.         c = c * x * x;
  22.     } while (abs(result - prevResult) > e);
  23.  
  24.     cout << result << endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement