#include #include using namespace std; double funkcja(double x) { return (x - 2)*(x + 2); } double zerowe(double a, double b, double e) { double c; while (b - a > e) { c = (a + b) / 2.0; if (funkcja(a)*funkcja(c) < 0) { b = c; } else { a = c; } } return c; } double falsi(double a, double b, double e) { double c; while (b - a > e) { c = (a*funkcja(b) - b*funkcja(a)) / (funkcja(b) - funkcja(a)); if (funkcja(a)*funkcja(c) < 0) { b = c; } else { a = c; } } return c; } int main() { double a, b, e; cout << "Podaj poczatek przedzialu\n"; cin >> a; cout << "Podaj koniec przedzialu\n"; cin >> b; cout << "Podaj dokladnosc\n"; cin >> e; cout << "Miejsce zerowe w punkcie "; cout << zerowe(a, b, e) << endl; cout << "Miejsce zerowe w punkcie "; cout << falsi(a, b, e) << endl; }