C/C++

Помогите пжж С++

D*
D@ny@ ***
284
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double ε = 1e-4, ln9 = log(9); unsigned n;
double S(double x)
{ double s = 1, p = 1, q = 0, y = x * ln9;
while (fabs(p / s) > ε) { ++q; p *= y / q; s += p; }
n = (unsigned)q; return s; }
double Y(double x) { return pow(9, x); }
void r(string c, unsigned k)
{ for (unsigned l = 0; l < k; l++) cout << c; }
int main() { double a = - 3, h = 0.1, i, x, sx, yx;
r(" ", 3); cout << 'x'; r(" ", 18); cout << "S(x)"; r(" ", 18);
cout << "Y(x)"; r(" ", 10); cout << "error"; r(" ", 7);
cout << "N\n"; r("—", 71); cout << endl;
for (i = 0; i <= 60; i++) { x = a + i * h; sx = S(x);
yx = Y(x); cout << setprecision(1) << setw(4) << x
<< setprecision(15) << fixed << setw(22) << sx <<
setw(22) << yx << setprecision(8) << setw(15) <<
sx / yx - 1 << setw(8) << n << endl; }
system("pause > nul"); return 0; }
Валентин Гусаров
Валентин Гусаров
29 440
Лучший ответ