#include <stdio.h> #include <math.h> int main() { double a,b,c; while(~scanf("%lf %lf %lf",&a,&b,&c)) { double det=b*b-4*a*c;//求△ if(a!=0) { double x1=((-b)-sqrt(det))/(2*a); double x2=((-b)+sqrt(det))/(2*a); double S=(-b)/(2*a); double M=sqrt(-det)/(2*a); if(det==0) printf("x1=x2=%.2lf\n",x1+0);//这里加0就能避免出现-0.00不是很理解 if(det>0) //有没有大佬解释一下@_@ printf("x1=%.2lf;x2=%.2lf\n",x1,x2); if(det<0) printf("x1=%.2lf-%.2lfi;x2=%0.2lf+%.2lfi\n",S,M,S,M); } else printf("Not quadratic equation\n"); } return 0; }