Advertisement
punidota

Untitled

Sep 19th, 2015
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include"stdafx.h"
  2. #include<conio.h>
  3. #include<vector>
  4. #include<clocale>
  5. #include<iostream>
  6. #include<math.h>
  7. using namespace std;
  8. double f(double x, double eps)
  9. {
  10. #define pi 3,1415926
  11.     double sum = (pi / 2);
  12.     long n = 1;
  13.     double fn = 1 / (3 * pow(x, 3.00));
  14.     while (eps < fabs(fn))
  15.     {
  16.         sum += fn;
  17.         n += 1;
  18.         fn *= pow(-1, n + 1);
  19.         fn /= (2 * n + 1) * pow(x, 2 * n + 1);
  20.     }
  21.     return sum;
  22. }
  23. int main()
  24. {
  25.     char sign[] = " ";
  26.     double x, fx, dx = 0.1, xn = 0, xk = 0, eps = 0.001;
  27.  
  28.     cout << "Enter xn : ";
  29.     cin >> xn;
  30.     printf("Enter xk : ");
  31.     cin >> xk;
  32.     printf("|----------------|\n");
  33.     printf("|    x   |  atan |\n");
  34.     printf("|----------------|\n");
  35.     for (x = xn; x <= xk; x += dx)
  36.     {
  37.         fx = f(x, eps);
  38.         if (x < 3)
  39.             sign[0] = '\0';
  40.         else
  41.             sign[0] = ' ';
  42.         printf("|%s%.4f|%s%.4f  |\n",
  43.             sign, x, sign, atan(fx));
  44.     }
  45.     printf("|---------------|\n");
  46.     system("pause");
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement