Advertisement
myloyo

cpp3

Oct 17th, 2023
1,088
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main() {
  7.     int x;
  8.     cin >> x;
  9.     double c = cos(x);
  10.     cout << fixed << setprecision(10) << c << endl;
  11.     int s = 2;
  12.     int chisl = 1;
  13.     int znam = 1;
  14.     double ans = 1;
  15.     int f = -1;
  16.     while (c != ans) {
  17.         znam *= (s - 1) * s;
  18.         chisl *= x * x;
  19.         ans += f * (chisl / znam);
  20.         f *= f;
  21.         s += 2;
  22.     }
  23.     cout << setprecision(10) << ans;
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement