括号没有对应好,第二个printf里多了一个%8.2f,a可能为0,改为
#include
#include
void main()
{
float a,b,c;
printf("plese input a,b,c:\n");
scanf("%f,%f,%f",&a,&b,&c);
if(a!=0){
if(b*b-4*a*c>0)
printf("%8.2f,%8.2f\n",(-b+sqrt(b*b-4*a*c))/(2*a),(-b-sqrt(b*b-4*a*c))/(2*a));
else if(b*b-4*a*c==0)
printf("%8.2f\n",-b/(2*a));
else
printf("方程无解");
}else{
printf("%8.2f\n",-c/b);
}
}
a可能是0,b也可能是0
用牛顿切线法吧?