解一元二次方程组时,当解为两个不相等实数根时,运行时出现-1.#IND,如何解决?

int main()
{

double a,b,c,d;

double x1,x2;

cin>>a>>b>>c;

d = b*b-4*a*c;

if( d<0 )
{
    cout<<"error";
}
else if ( d==0 )
{
    x1=x2=-b/(2*a);
    cout<<x1;
}
else
{
    x1=-b/(2*a)+sqrt(4*a*c-b*b)/(2*a);
    x2=-b/(2*a)-sqrt(4*a*c-b*b)/(2*a);
    cout<<x1<<" "<<x2;
}
return 0;

}

sqrt (4*a*c-b*b) 小于0

x1=-b/(2*a)+sqrt(4*a*c-b*b)/(2*a);
x2=-b/(2*a)-sqrt(4*a*c-b*b)/(2*a);
->
x1=-b/(2*a)+sqrt(b*b-4*a*c)/(2*a);
x2=-b/(2*a)-sqrt(b*b-4*a*c)/(2*a);

//sqrt开方数要求大于等于0
//并且是对(b*b-4*a*c)开方,要判断括号内是不是大于等于0