/* *方程:2*x*x*x - 4*x*x + 3*x - 6 = 0; */ #include <iostream> #include <cmath> using namespace std; double f(double x); int main(void){ double x1 = -10, x2 = 10, x; while(fabs(x1-x2)>=1e-6){ x = (x1+x2)/2; if(f(x)*f(x1)<0){ x2 = x; }else{ x1 = x; } } cout << x1 << endl; } double f(double x){ return 2*x*x*x - 4*x*x + 3*x - 6; }