Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <conio.h>
  4. using namespace std;
  5.  
  6. int main() {
  7.    
  8.     double e, x, sum = 0, s, fact;
  9.     int i, k = 0;
  10.    
  11.     cout << "x = ";
  12.     cin >> x;
  13.    
  14.     cout << "e = ";
  15.     cin >> e;
  16.    
  17.     do
  18.     {  
  19.         k++;
  20.         fact = 1;
  21.         for (i = 1; i <= k; ++i)
  22.         fact *= i;
  23.        
  24.         s = pow(-1.0, k) * pow(0.5 * x, 2.0 * k + 1) / pow(fact, 2) / (k + 1);
  25.         sum += s;  
  26.         }
  27.     while (s > e);
  28.      
  29.     cout << "summa ravha " << sum;
  30.    
  31.  getch ();
  32.  return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement