程序出了小问题,帮忙看看,输入输出问题
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);
}
main()
{
float a,b,c,d;
printf("Input a,b,c,d:");
scanf("%f,%f,%f,%f",&a,&b,&c,&d);
printf("Equantion is:%5.2fx^3+%5.2fx^2+%5.2fx+%5.2f=0",a,b,c,d); 为什么输出时只能输出a值,其余都是0?
printf("\nx=%10.7f\n",solut(a,b,c,d));
getch();
}