Advertisement
Guest User

123

a guest
Oct 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. long double f_xmax(double x);
  2. long double f_sum(double x);
  3.  
  4. int main()
  5. {
  6.     double x = -2, h = 0.4;
  7.     int n = (2+2)/h+1;
  8.     double array[2][n];
  9.     for (int i = 0; i < n; i++)
  10.     {
  11.         array[0][i] = x;
  12.         if (x > 0)
  13.         {
  14.             array[1][i] = f_xmax(x);
  15.         }
  16.         else
  17.         {
  18.             array[1][i] = f_sum(x);
  19.         }
  20.         x += h;
  21.     }
  22.     for (int i = 0; i < 2; i++)
  23.     {
  24.         for (int j = 0; j < n; j++)
  25.         {
  26.             cout << array[i][j] << "\t";
  27.         }
  28.         cout << endl;
  29.     }
  30. }
  31.  
  32. long double f_xmax(double x)
  33. {
  34.     double tempSum = pow(x,3)/1/5;
  35.     return tempSum;
  36. }
  37.  
  38. long double f_sum(double x)
  39. {
  40.     double tempSum = 0;
  41.     int k = 1;
  42.     for (int i = 0; i < 3; i++)
  43.     {
  44.         tempSum += pow(x,2) + pow(x,k)/k;
  45.         k++;
  46.     }
  47.     return tempSum;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement