#include <stdio.h> #include <math.h> int main() { float a = 0; float b = 0; float c = 0; while (scanf("%f%f%f", &a, &b, &c) == 3) { float d = pow(b, 2) - 4 * a * c; if (a == 0) printf("Not quadratic equation\n"); else { if (d == 0) { float mp = -b + sqrt(d);//用来判断特殊情况0(4 0 0) if(mp==0) printf("x1=x2=%.2f\n", mp); else printf("x1=x2=%.2f\n",(-b+sqrt(d))/2.0/a); } else if (d > 0) printf("x1=%.2f;x2=%.2f\n", (-b - sqrt(d)) / 2.0 / a, (-b + sqrt(d)) / 2.0 / a); else { float r = -b / (2.0 * a); float v = sqrt(-d) / (2.0 * a); printf("x1=%.2f-%.2fi;x2=%.2f+%.2fi\n", r, v, r, v); } } } return 0; }