#include <stdio.h> #include<math.h> int main() { double a, b, c, derta; double x1; double x2; while ((scanf("%lf %lf %lf", &a, &b, &c)) != EOF) { if (a == 0) printf("Not quadratic equation\n"); else { derta = b * b - 4 * a * c; x1 = (-b - sqrt(derta)) / (2* a); x2 = (-b + sqrt(derta)) / (2* a); if(x1==0.00&&x2==0.00)//这里很奇怪,要自己把x1、x2等于0.00的情况写出来,要不然输出的结果始终是-0.00 printf("x1=x2=0.00\n"); else if (derta == 0) printf("x1=x2=%.2lf\n", x1); else if (derta > 0) printf("x1=%.2lf;x2=%.2lf\n", x1, x2); else printf("x1=%.2lf-%.2lfi;x2=%.2lf+%.2lfi\n", -b / (2 * a), sqrt(-derta) / (2 * a), -b / (2 * a), sqrt(-derta) / (2 * a)); } } return 0; }