c语言 为啥一直有错 求解
输入参数a,b,c,求二次方程a*x^2+b*x+c=0的根。#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void main()
{
float a,b,c,d;
printf("输入一元二次方程a= , b= , c= \n");
scanf("a=%f, b=%f, c=%f",&a,&b,&c);
d=b*b-4*a*c;
if(a==0)
{
if(b==0)
{
if(c==0)
{
printf("0=0参数对方程无意义!");
}
else
{
printf("C!=0方程不成立");
}
}
else
{
printf("x=%f\n",-c/b);
}
}
else
if(d>=0)
{
printf("x1=%f\n",(-b+sqrt(d))/(2*a));
printf("x2=%f\n",(-b-sqrt(d))/(2*a));
}
else
{
printf("x1=%f+%f\n",-b/(2*a),sqrt(-d)/(2*a));
printf("x2=%f-%f\n",-b/(2*a),sqrt(-d)/(2*a));
}
return 0;
}