求a*x^3+b*x^2+c*x+d=0的根 #include<iostream> #include<cmath> using namespace std; float solut(float,float,float,float); int main() { float a,b,c,d; cout<<"请输入a,b,c,d:"; cin>>a>>b>>c>>d; cout<<solut(a,b,c,d); return 0; } float solut(float a,float b,float c,float d) { float x=1,x0,f,f1; do { x0=x; f=((a*x0+b)*x0+c)*x0+d; f1=(3*a*x0+2*b)*x0+c; x=x0-f/f1; } while(fabs(x-x0)>=1e-3); return x; }