
#include<stdio.h>
#include<math.h>
int main()
{
float x1,x2,x0,fx1,fx2,fx0;
do
{
printf("Enter two numbers:\n");
scanf("%f%f",&x1,&x2);
fx1=x1*(2*x1*(x1-2)+3)-6;
fx2=x2*(2*x2*(x2-2)+3)-6;
}while(fx1*fx2>0);
do
{
x0=(x1+x2)/2;
fx0=x0*(2*x0*(x0-2)+3)-6;
if(fx1*fx0<0)
{
x2=x0;
fx2=fx0;
}
else
{
x1=x0;
fx1=fx0;
}
}while(fabs(x0)>=1e-5); //如果是<=,则只会执行一次本循环,所以直接计算并输出x0=(x1+x2)/2。
printf("%6.2f\n",x0);
return 0;
}


