constk

DefiniteIntegral_mainFile

Sep 8th, 2020 (edited)
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.53 KB | None | 0 0
  1. #include <iostream>
  2. #include "windows.h"
  3.  
  4. #include "DefiniteIntegral.h"
  5.  
  6. // [2; 4]
  7. double f(double x) {
  8.     return pow(x, pow(log(x), x)) * pow(log(x), pow(x, log(x)));
  9. }
  10.  
  11. int main() {
  12.     using namespace std;
  13.  
  14.     SetConsoleCP(1251);
  15.     SetConsoleOutputCP(1251);
  16.  
  17.     DefiniteIntegral * integral = new DefiniteIntegral(f, 2.0, 4.0);
  18.  
  19.     cout << "Метод левых прямоугольников: " << endl;
  20.     cout << "Количество итераций   = " << integral->getAmountOfIterations("LeftRecktangle") << endl;
  21.     cout << "Определённый интеграл = " << integral->calculate("LeftRecktangle") << endl;
  22.     cout << "#######################################################" << endl;
  23.  
  24.     cout << "Метод правых прямоугольников: " << endl;
  25.     cout << "Количество итераций   = " << integral->getAmountOfIterations("RightRecktangle") << endl;
  26.     cout << "Определённый интеграл = " << integral->calculate("RightRecktangle") << endl;
  27.     cout << "#######################################################" << endl;
  28.  
  29.     cout << "Метод центральных прямоугольников: " << endl;
  30.     cout << "Количество итераций   = " << integral->getAmountOfIterations("CenterRecktangle") << endl;
  31.     cout << "Определённый интеграл = " << integral->calculate("CenterRecktangle") << endl;
  32.     cout << "#######################################################" << endl;
  33.  
  34.     cout << "Метод трапеций: " << endl;
  35.     cout << "Количество итераций   = " << integral->getAmountOfIterations("Trapeze") << endl;
  36.     cout << "Определённый интеграл = " << integral->calculate("Trapeze") << endl;
  37.     cout << "#######################################################" << endl;
  38.  
  39.     cout << "Метод Симпсона: " << endl;
  40.     cout << "Количество итераций   = " << integral->getAmountOfIterations("Simpson") << endl;
  41.     cout << "Определённый интеграл = " << integral->calculate("Simpson") << endl;
  42.     cout << "#######################################################" << endl;
  43.  
  44.     cout << "Метод Ньютона: " << endl;
  45.     cout << "Количество итераций   = " << integral->getAmountOfIterations("Newton") << endl;
  46.     cout << "Определённый интеграл = " << integral->calculate("Newton") << endl;
  47.     cout << "#######################################################" << endl;
  48.  
  49.     cout << "Конец программы. ";
  50.     system("pause");
  51.     return 0;
  52. }
Add Comment
Please, Sign In to add comment