大家看看这题错哪里了
题目是用牛顿迭代法求方程ax^3+bx^2+cx+d=0在x=1附近的根,错哪里了?????#include<stdio.h>
#include<math.h>
void main()
{
float hs(int x[4]);
int i,a[4];
float b;
printf("please input four numbers\n");
for(i=0;i<=3;i++)
scanf("%d",&a[i]);
b=hs(a);
printf("The result is %f\n",b);
}
float hs(int x[4])
{
float m,n=1,f,f1;
for(;fabs(m-n)<=0.000001;)
{
m=n;
f=x[0]*m*m*m+x[1]*m*m+x[2]*m+x[3];
f1=3*x[0]*m*m+2*x[1]*m+x[2];
n=m-f/f1;
}
return(n);
}