#include <stdio.h> #include<math.h> int main() { float a, b , c; while (scanf("%f %f %f", &a, &b,&c) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to float derta = b*b-4*a*c; float x1 ,x2; if(a==0) { printf("Not quadratic equation"); } else { if(derta==0) { x1=-b/(2*a)+0; printf("x1=x2=%.2f\n",x1); } else if(derta>0) { x1=(-b-sqrt(b*b-4*a*c))/(2*a); x2=(-b+sqrt(b*b-4*a*c))/(2*a); printf("x1=%.2f;x2=%.2f",x1,x2); } else { if(b!=0) { printf("x1=%.2f-%.2fi;x2=%.2f+%.2fi\n",-b/(2*a),sqrt(-(b*b-4*a*c))/(2*a),-b/(2*a),sqrt(-(b*b-4*a*c))/(2*a)); } else if(b==0) { printf("x1=0.00-%.2fi;x2=0.00+%.2fi\n",sqrt(-(b*b-4*a*c))/(2*a),sqrt(-(b*b-4*a*c))/(2*a)); } } } } return 0; }