Sitisom

1.7 b

Oct 19th, 2018
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     double y, x, t, eps; int i,n;
  9.  
  10.     cout << "enter eps = ";
  11.     cin >> eps;
  12.     cout << "enter n = ";
  13.     cin >> n;
  14.     for (int j = 0; j < n; j++) {
  15.         cout << "enter x = ";
  16.         cin >> x;
  17.         i = 0;
  18.         y = 0;
  19.         t = 1;
  20.         while (abs(t) > eps)
  21.         {
  22.             y += t;
  23.             i++;
  24.             t = -t * pow(x*x - x + 1, 2) / (2*i*(2*i-1));
  25.         }
  26.         cout << y << endl;
  27.         cout << cos(x*x - x + 1) << endl;
  28.     }
  29.    
  30.     system("pause");
  31.     return 0;
  32. }
Add Comment
Please, Sign In to add comment