DasShelmer

3.5.19

Oct 13th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. double calculate(double x) {
  7.     x = abs(x);
  8.     if (x < 2)
  9.         return sqrt(5 * pow(x, 2) + 5);
  10.     else if (x < 10)
  11.         return x / sqrt(5 * pow(x, 2) + 5);
  12.     else
  13.         return 0.0;
  14. }
  15. int main() {
  16.     setlocale(LC_ALL, "Russian");
  17.     double a, b, h;
  18.     cout << "Введите границы отрезка для x [a, b]: ";
  19.     cin >> a >> b;
  20.     cout << "Введите значение шага (h): ";
  21.     cin >> h;
  22.     cout << "     x    " << "    y" << endl;
  23.  
  24.     for (double x = a; x <= b; x += h) {
  25.         cout << setw(6) << setprecision(3) << x;
  26.         cout << setw(9) << setprecision(3) << calculate(x) << endl;
  27.     }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment