#include<stdio.h>
#include<math.h>
#include<math.h>
double fun(double temp){
return 2*temp*temp*temp-4*temp*temp+3*temp-6;
}
return 2*temp*temp*temp-4*temp*temp+3*temp-6;
}
int main(){
double max,min,f,temp,f1,f2;
max =10;
min =-10;
f2= 1;
while(fabs(f2)>=1e-5){ //此处错在条件上
temp = (max + min)/2;
f1=fun(max);
f2=fun(temp);
if (f1*f2<0)
min = temp;
else
max = temp;
}
printf("%f",temp);
return 0;
}
double max,min,f,temp,f1,f2;
max =10;
min =-10;
f2= 1;
while(fabs(f2)>=1e-5){ //此处错在条件上
temp = (max + min)/2;
f1=fun(max);
f2=fun(temp);
if (f1*f2<0)
min = temp;
else
max = temp;
}
printf("%f",temp);
return 0;
}