#include using IterationF = function; using LoopF = function; double iteration(double x, double i); double mp_for(int min, int max, IterationF &f); double mp_while(int min, int max, IterationF &f); double mp_do_while(int min, int max, IterationF &f); void lab3() { LoopF loopF; IterationF f; double x, y; int n; char c; cout << "Enter x: "; cin >> x; f = [=](int i) { return iteration(x, i); }; cout << "Enter N: "; cin >> n; loop // while (1) { cout << endl << "Select mode (F/W/D): "; cin >> c; switch (c) { case 'f': case 'F': loopF = mp_for; break; case 'w': case 'W': loopF = mp_while; break; case 'd': case 'D': loopF = mp_do_while; break; default: cout << "Invalid mode, exiting!" << endl; return; } y = pow(loopF(1, n, f), 1.2 * x); cout << "Result y(" << x << ") = " << y << endl; } } double iteration(double x, double i) { return 2.8 * pow(x, 4.5) + cbrt(i); } double mp_for(int min, int max, IterationF &f) { double res = 1.0; for (int i = min; i <= max; i++) { res += f(i); } return res; } double mp_while(int min, int max, IterationF &f) { double res = 1.0; int i = min; while (i <= max) { res += f(i); i++; } return res; } double mp_do_while(int min, int max, IterationF &f) { double res = 1.0; if (min >= max) return res; int i = min; do { res += f(i); i++; } while (i <= max); return res; }