include<stdio.h>
include<math.h>
int main()
{
double a, b, c;
while (~scanf("%lf%lf%lf", &a, &b, &c))
{
double x1, x2;
double date = b * b - 4 * a*c;
if (a != 0)
{
if (b*b - 4 * a*c < 0)//我知道问题所在了,此时根号下是负数 { //这里的计算有问题 x1 -nan(ind)?? x1 = (-b) / (2 * a); x2 = (-b) / (2 * a);printf("x1=%.2lf-%.2lfi;x2=%.2lf+%.2lfi\n", (-b) / (2 * a), sqrt(-date) / (2 * a), (-b) / (2 * a), sqrt(-date) / (2 * a));//关键在于分开写 //printf("x1=%.2lf+%lfi;x2=%.2lf-%lfi\n", x1, sqrt(-(b*b - 4 * a*c)) / (2 * a), x2, sqrt(-(b*b - 4 * a*c)) / (2 * a)); } else if (b*b - 4 * a*c > 0) { x1 = (-b - sqrt(b*b - 4 * a*c)) / (2 * a); x2 = (-b + sqrt(b*b - 4 * a*c)) / (2 * a); printf("x1=%.2lf;x2=%.2lf\n", x1, x2); } else if ((b*b - 4 * a*c) == 0) { x1 = x2 = -(b/(2*a) ); printf("x1=x2=%.2lf\n", x1); } } else printf("Not quadratic equation\n"); }return 0;