#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
float f(float x) //定义函数
{
return pow(x, 3) - 5 * pow(x, 2) + 8 * pow(x, 1) - 4;
}
int main()
{
float x0, x1, x2;
do
{
printf("请输入两个数\n");
scanf("%f%f", &x1, &x2);
} while (f(x1) * f(x2) >= 0);
do
{
x0 = (x1 + x2) / 2;
if (f(x0) * f(x1) < 0) x2 = x0;
else x1 = x0;
} while (fabs(f(x0)) > 10e-8);
printf("%7.2f", x0);
return 0;
}