#include <stdio.h>
#include <math.h>
int main()
{
float a, b, c, d;
float x1, x2;
while(scanf("%f %f %f", &a, &b, &c) != EOF)
{
if(a == 0)
printf("Not quadratic equation\n");
else
{
d = b * b - 4 * a * c;
if(d == 0 && b !=0){ //要考虑到b=0与b!=0的区别,不加b!=0的话,结果会是-0.00,而不是0.00
x1 = (-b)/(2*a);
printf("x1=x2=%.2f\n", x1);
}
else if(d == 0 && b == 0)
printf("x1=x2=0.00\n");
else if(d > 0){
x1 = (-b - sqrt(d))/(2*a); //根据示例,两个解有特定顺序,先是减,后是加,否则会报错。
x2 = (-b + sqrt(d))/(2*a);
printf("x1=%.2f;x2=%.2f\n", x1, x2);
}
else {
float m1 = (-b)/(2*a);
float m2 = (sqrt(-d)) / (2*a);
printf("x1=%.2f-%.2fi;x2=%.2f+%.2fi\n", m1, m2, m1, m2);
}
}
}
return 0;
}
#include <math.h>
int main()
{
float a, b, c, d;
float x1, x2;
while(scanf("%f %f %f", &a, &b, &c) != EOF)
{
if(a == 0)
printf("Not quadratic equation\n");
else
{
d = b * b - 4 * a * c;
if(d == 0 && b !=0){ //要考虑到b=0与b!=0的区别,不加b!=0的话,结果会是-0.00,而不是0.00
x1 = (-b)/(2*a);
printf("x1=x2=%.2f\n", x1);
}
else if(d == 0 && b == 0)
printf("x1=x2=0.00\n");
else if(d > 0){
x1 = (-b - sqrt(d))/(2*a); //根据示例,两个解有特定顺序,先是减,后是加,否则会报错。
x2 = (-b + sqrt(d))/(2*a);
printf("x1=%.2f;x2=%.2f\n", x1, x2);
}
else {
float m1 = (-b)/(2*a);
float m2 = (sqrt(-d)) / (2*a);
printf("x1=%.2f-%.2fi;x2=%.2f+%.2fi\n", m1, m2, m1, m2);
}
}
}
return 0;
}