#include #include #include using namespace std; float fun(float x, float e, int &n) { float s = 0, a = (x - 1); n = 0; while (fabs(a)>=e) { s += a; a *= -pow(x - 1, 2) / 2; n++; } return s; } int main() { float a, b, e, h, f, x; cout << "a="; cin >> a; cout << "b="; cin >> b; cout << "e="; cin >> e; cout << "h="; cin >> h; int n, i; cout << setprecision(3); cout << "i\t x\t f(x)\t n\n"; for (x = a, i = 2; x <= b; x += h, i++) { f = fun(x, e, n); cout << i << "\t" << x << "\t" << f << "\t" << n << endl; } system("pause"); return 0; }