程序没错啊,但运行结果是错的,求大神帮忙。
#include<stdio.h>#include<math.h>
void calroot(double a,double b,double c);
void main()
{
double a,b,c;
scanf("%f%f%f",&a,&b,&c);
calroot(a,b,c);
}
void calroot(double a,double b,double c)
{
double d,e,x1,x2;
d=b*b-4*a*c;
if (0==a)
if (0==b)
printf("方程无解\n");
else
printf("x1=x2=%f\n",-c/b);
else if (0==d)
printf("x1=x2=%f\n",-b/(2*a));
else if (d>0)
{
e=sqrt(d);
printf("x1=%f\n",(-b+e)/(2*a));
printf("x2=%f\n",(-b-e)/(2*a));
}
else
printf("方程无实根");
return 0;
}