#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
struct Table {
double xn = 0;
double xk = 0;
double h = 0;
void set(const double _xn, const double _xk, const double _h) {
xn = _xn;
xk = _xk;
h = _h;
}
private:
double f(const double x) const {
return log(x * x) - x + 4.0;
}
friend ostream& operator<<(ostream& out, const Table& table) {
const auto end = table.xk + table.h / 10.0;
cout.setf(ios::fixed);
for (auto x = table.xn; x < end; x += table.h) {
auto result = table.f(x);
out << setw(6) << setprecision(2) << x;
out << setw(21) << setprecision(15) << result << '\n';
}
return out;
}
};
int main() {
constexpr auto xn = 0.1;
constexpr auto xk = 29.0;
constexpr auto h = 0.2;
Table table;
table.set(xn, xk, h);
cout << table;
}
табулирования функции на заданном промежутке с шагом 0.2.
Произвести выравнивание результатов по колонкам.