Advertisement
DasShelmer

5.2.19

Oct 15th, 2019
186
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 <math.h>
  3. using namespace std;
  4.  
  5. int main() {
  6.     setlocale(LC_ALL, "Russian");
  7.     int n;
  8.     double x, x2, xP, p = 1.0;
  9.     cout << "Введите значение n (n >= 2): ";
  10.     cin >> n;
  11.    
  12.     cout << "Введите значение x: ";
  13.     cin >> x;
  14.     x2 = x * x;// x^2
  15.     xP = x; // x^(2*n - 1)
  16.  
  17.     for (int i = 2; i <= n; i++) {
  18.         xP *= x2;
  19.         p *= 1 + (i % 2 == 0? 1 : -1) * xP / (pow(i, 3) - 1);
  20.     }
  21.     printf("P: %6.14lf", p);
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement