Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int k;
  8.     cout << "k="; cin >> k;
  9.     float x;
  10.     cout << "x="; cin >> x;
  11.     float a = x;
  12.     float s = a;
  13.     cout << "a = " << a << endl;
  14.     for (int i = 2; i <= k; i++) {
  15.         a = (-1) * a * pow(x, 2) / ((2 * i - 1) * (2 * i - 2));
  16.         s += a;
  17.     }
  18.     cout << "s = " << s << endl;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement