为什么a,b,c,d无法正常输入???拜托各位了,,,下面一段程序是牛顿迭代法求根
#include<stdio.h>
#include<math.h>
float Solu(float a,float b,float c,float d,float x0,float x1)
{
if(fabs(x0-x1)>1e-5)
{
x0=x1;
x1=x0-(a*x0*x0*x0+b*x0*x0+c*x0+d)/(3*a*x0*x0+2*b*x0+c);
return Solu(a,b,c,d,x0,x1);
}
else
{
return x1;
}
}
int main()
{
float a,b,c,d,x0,x1;
printf("\n输入方程的系数a、b、c、d:\n");
scanf("%f%f%f%f",&a,&b,&c,&d);
printf("\n方程是:%5.2fx^3+%5.2fx^2+%5.2fx+%5.2f=0");
x0=1.0;
x1=x0-(a*x0*x0*x0+b*x0*x0+c*x0+d)/(3*a*x0*x0+2*b*x0+c);
printf("\nX=%10.7f\n",Solu(a,b,c,d,x0,x1));
}