程序最后的复数答案显示不出来 该怎么改?
#include <iostream.h>#include<cmath>
void main()
{
int a,b,c;
double x1,x2;
int q;
cout<<"input a:"<<endl;
cout<<"input b:"<<endl;
cout<<"input c:"<<endl;
cin>>a>>b>>c;
q=b*b-4*a*c;
cout<<q<<endl;
if(a==0)
{
cout<<"不是二次方程"<<endl;
}
else if(q==0)
{
cout<<"有两个相等实根:"<<endl;
x1=((-b)+sqrt(q))/(2*a);
cout<<"x1=x2="<<x1<<endl;
}
else if(q>0)
{
cout<<"有两个不相等实根:"<<endl;
x1=((-b)+sqrt(q))/(2*a);
cout<<"x1="<<x1;
x2=((-b)-sqrt(q))/(2*a);
cout<<"x2="<<x2;
}
else(q<0);
{
cout<<"有两个复数根:"<<endl;
double x=(-b)/2*a;
double y=sqrt(q)/(2*a);
cout<<"x1="<<x<<"+"<<"("<<y<<")"<<"*i"<<endl;
cout<<"x2="<<x<<"-"<<"("<<y<<")"<<"*i"<<endl;
}
}