回复 2楼 八画小子
#include<stdio.h>#include<math.h>
#include<stdlib.h>
double product1(double)
double product2(double,double)
void main()
{
double a,b,a1,b1,x;
a=-10; b=10;
a1=a; b1=b;
x=product2(a1,b1);
printf("X=%f\n",x);
}
product1(double x)
{
double y;
y=2*pow(x,3)-4*pow(x,2)+3*x-6;
return y;
}
product2(double m,double n)
{
double x,y,y1,y2,a,b;
a=m; b=n;
while(1)
{
x=(a+b)/2;
y=product1(x);
y1=product1(a);
y2=product1(b);
if(y1*y<0) {b=x;if(fabs(fabs(y1)-fabs(y))<=1) return x;}
if(y2*y<0) {a=x;if(fabs(fabs(y2)-fabs(y))<=1) return x;}
}
}