C语言怎么样用二分法求方程的解

问题描述:

C语言怎么样用二分法求方程的解
用二分法求2X^3-4X^2+3X-6=0在(-10,10)之间的根~要求用WIN-TC

x1,x2请输入-10,10
#include
#include
void main()
{
float x0,x1,x2,f0,f1,f2;
do
{
printf("please enter x1 & x2:\n");
scanf("%f,%f",&x1,&x2);
f1=((2*x1-4)*x1+3)*x1-6;
f2=((2*x2-4)*x2+3)*x2-6;
}
while ((f1*f2)>0);
do
{
x0=(x1+x2)/2;
f0=((2*x0-4)*x0+3)*x0-6;
if ((f0*f1)=1e-5);
printf("the root of equation is :%f\n",x0);
}