include <stdio.h> include <math.h> int main() { flaot solution(float a,flaot b,float c,float d); float a; float b; float c; float d; scanf("%f%f%f%f",&a,&b,&c,&d); printf("the soulution is %f ",solution(a,b,c,d); return 0; } float solution(float a, float b, float c,float d) { float x = 1.5; float x0; float f; float fd; while(fabs(x - x0)>= 1e-5) { x0 = x; f = a * x0 * x0 * x0 + b * x0 * x0 +c * x0 + d; fd = 3 * a * x0 * x0 + 2 * b * x0 +c; x = x0 - f / fd; } return x; }
转自:https://blog.csdn.net/qq_31029351/article/details/53311285