求解一元二次方程,求指教
#include<stdio.h>#include<math.h>
int main()
{
int a,b,c;
double x1,x2,x,y,z1,z2,u;
scanf("%d %d %d",&a,&b,&c);
x=(double)(-c/a);
u=(double)(-c/b);
y=b*b-4*a*c;
x1=(-b+sqrt(y))/2*a;
x2=(-b-sqrt(y))/2*a;
z1=b/(2*a)+sqrt(y)/(2*a);
z2=b/(2*a)-sqrt(y)/(2*a);
if(a==0&&b==0) printf("Input error!\n");
else if(a==0&&b!=0) printf("x=%lf\n",u);
else if(a!=0)
{
//if(b==0) printf("x1=%lf\nx2=%lf\n",sqrt(x),-sqrt(x));
else if(y==0) printf("x1=x2=%lf\n",x1);
else if(y>0) printf("x1=%lf\n x2=%lf\n",x1,x2);
else if(y<0)
{if(b==0) printf("x1=%lfi\nx2=%lfi\n",0.5/a,-0.5/a);
else printf("x1=%lf+%lfi\n",-0.5*b/a,0.5/a);printf("x2=%lf%lfi\n",-0.5*b/a,-0.5/a);}
}
return 0;