Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- using namespace std;
- float f_u(float x, float e, int &n) {//Функция для просчета суммы для выбранной точки отрезка
- n = 2;
- float sum = 1, a = x;
- while (abs(a) >= e) {
- a *= (x*x)/(((2 * n - 1)) * 2);
- sum += a;
- n++;
- }
- return sum;
- }
- int main() {
- float a, b, h, e, x, f;
- int n, i = 1;
- cout << "Enter a: ";
- cin >> a;
- cout << "Enter b: ";
- cin >> b;
- cout << "Enter step h: ";
- cin >> h;
- cout << "Enter epsilon: ";
- cin >> e;
- cout << "i" << '\t' << "x" << '\t' << "f(x)" << '\t' << "n" << endl;
- for (i, x = a; x <= b; x += h, i++) {
- f = f_u(x, e, n);
- cout << i << '\t' << x << '\t' << f << '\t' << int(n - 2) << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement