我的这个求根程序到底问题出在哪里了?
#include<stdio.h>#include<math.h>
int main()
{double a,b,c;
double x1,x2,disc,realpart,imagpart,root;
disc=b*b-4*a*c;
realpart=-b/(2*a);
imagpart=sqrt(-disc)/(2*a);
printf("There is a equation :a*x*x+b*x+c=0\n");
printf("please enter a,b,c:");
scanf("%lf,%lf,%lf",&a,&b,&c);
if(fabs(a)<1e-6)
{printf("it is not a 二次方程!");
root=-(b/c);
printf("the root is %f\n",root);
}
else /* (a!=0) */
{
if(fabs(disc)>1e-6)
{ if(disc>1e-6)
{printf("it is a 二次方程!");
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
printf("there are two roots: x1=%f,x2=%f",x1,x2);}
else
{printf("it is a 根为虚数的二次方程! it has two complex roots: ");
printf("x1=%8.4lf+%8.4lfi\n",realpart,imagpart);
printf("x2=%8.4lf-%8.4lfi\n",realpart,imagpart);}
}
else
{printf("it has two equal root:%8.4lf\n",-b/(2*a));}
}
return 0;
}