#include #include float f(float x) { return (x*x)-1; } int main() { float a, b, x0, eps; int i; printf("Podaj przedzial izolacji:"); scanf("%f%f", &a, &b); eps = 1e-6; i=0; while(fabs(a-b)>eps) { i++; x0 = (a+b)/2; printf("%f %f %f\n", a, b, b-a); if (fabs(f(x0)) < eps) break; if(f(a)*f(x0) < 0) b=x0; else a=x0; } printf("x0 = %f\niterations %d\n", x0, i); printf("f(%g)=%g\n", x0, f(x0)); return 0; }