#include <stdio.h> #include <math.h> //一元二次方程ax2 + bx + c = 0的根 int main() { float a,b,c; //多组输入输入三个数 while(scanf("%f %f %f",&a,&b,&c) != EOF) { int gen = b*b - 4*a*c; if(0 == a) printf("Not quadratic equation\n"); else if(a != 0) { if(gen == 0) { if(b == 0) printf("x1=x2=0.00\n"); else printf("x1=x2=%.2f\n",-b / (2*a)); } else if(gen >0) printf("x1=%.2f;x2=%.2f\n",(((-b)-sqrt(gen))/(2*a)),(((-b)+sqrt(gen))/(2*a))); else { printf("x1=%.2f-%.2fi;x2=%.2f+%.2fi\n", -b / (2*a),sqrt(-gen) / (2*a),-b / (2*a),sqrt(-gen) / (2*a)); } } } return 0; }