Advertisement
Filage

lab7_4

Nov 20th, 2023
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. cout << "Задание 4.6\n";
  2.         eps = 0.1;
  3.         s = 0;
  4.         n = 0;
  5.         cout << "Введите X1\n";
  6.         x1 = TakeNum(-10, 10);
  7.         cout << "Введите X2\n";
  8.         x2 = TakeNum(-10, 10);
  9.         cout << "Введите dx\n";
  10.         dx = TakeNum(1, 10);
  11.  
  12.        
  13.         cout << ("   x    |    f(x)   |   count\n");
  14.         for (double i = x1; i <= x2; i += dx) {
  15.             count = 0;
  16.             temp = i;
  17.             fac = 1;
  18.             n = 0;
  19.             s = 0;
  20.             while (fabs(temp) > eps) {
  21.                 for (int j = 1; j < 2 * n; j++)
  22.                     fac *= j;
  23.                 temp = (pow((-1), n) * (pow(i, 2 * n))) / fac;
  24.                 s += temp;
  25.                 n++;
  26.                 count++;
  27.             }
  28.             cout << fixed << setprecision(3) << i << "   |   " << fixed << setprecision(3) << s << "   |     " << count << endl;
  29.         }
  30.         cout << "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement