Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- void h_line(streamsize);
- unsigned series(const double, const double, double &);
- int main() {
- double x_beg, x_end, dx, arg = 0, eps;
- cout << "x_beg?.. "; cin >> x_beg;
- cout << "x_end?.. "; cin >> x_end;
- cout << "dx?.. "; cin >> dx;
- cout << "exp?.. "; cin >> eps;
- if (x_end > x_beg && dx > 0 && eps > 0 && eps >= 1e-14) {
- unsigned q;
- unsigned char v = 179;
- streamsize lr = 9, c = 19, tb = lr * 2 + c + 10, acc = 16;
- cout << "\n\t\tTITLE TABLE\n";
- h_line(tb);
- cout << v << ' '
- << setw(lr) << "Argument"
- << ' ' << v << ' '
- << setw(c) << "Function"
- << ' ' << v << ' '
- << setw(lr) << "Quantuty"
- << ' ' << v << endl;
- h_line(tb);
- for (double x = x_beg; x <= x_end + dx / 2; x += dx) {
- if (abs(x) > 1) {
- q = series(x, eps, arg);
- cout << v << ' '
- << setw(lr) << x
- << ' ' << v << ' '
- << setw(c) << setprecision(acc) << arg
- << ' ' << v << ' '
- << setw(lr) << q
- << ' ' << v << endl;
- } else cout << v << ' '
- << setw(lr) << x
- << ' ' << v << ' '
- << "\t Argument error!\a"
- << setw(acc - 2) << ' ' << v << endl;
- h_line(tb);
- }
- } else cout << "\tError!\a\n";
- cin.get(); cin.get();
- return 0;
- }
- void h_line(streamsize _h) {
- if (_h > 80 ) _h = 80;
- unsigned char h = 196;
- for (streamsize n = 0; n < _h; n++) cout << h;
- cout << endl;
- }
- unsigned series(const double _x, const double _exp, double & _arg) {
- unsigned n = 0;
- int dx = 1;
- double arg = log((_x + 1) / (_x - 1));
- double sum = 0, temp = arg * 2;
- while (abs(abs(temp) - abs(arg)) > _exp) {
- ++n;
- sum += 1 / (dx * pow(_x, dx));
- temp = 2 * sum;
- dx += 2;
- }
- _arg = temp;
- return n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement