#include
#include
int main()
{
float a = 0.0f;
float b = 0.0f;
float c = 0.0f;
float d = 0.0f;
float x1 = 0.0f;
float x2 = 0.0f;
float x = 0.0f;
printf("请输入a,b,c值:n");
scanf("%f %f %f", &a, &b, &c);
if (a == 0)
{
x1 = x2 = -c/b;
}
else
{
d = b * b - 4 * a * c;
if (d >= 0)
{
x1 = -(b + sqrt(d)) / (2.0*a);
x2 = -(b - sqrt(d)) / (2.0 * a);
}
else
{
x1 = -(b + sqrt(-d)) / (2.0 * a);
x2 = -(b - sqrt(-d)) / (2.0 * a);
}
}
printf("x1=%f x2=%f", x1, x2);
return 0;
}



