輸入1 0 0 都會被判斷錯誤,但我不知道哪裡錯了,能幫幫我嗎。
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
double a,b,c,s1,s2,t;
while(cin>>a>>b>>c)
{
s1=(b*(-1)+sqrt(b*b-4*a*c))/(2*a);
s2=(b*(-1)-sqrt(b*b-4*a*c))/(2*a);
if(s2>s1)
{
t=s1;
s1=s2;
s2=t;
}
if(s1!=s2)
{
cout<<"Two different roots x1="<<s1<<" , "<<"x2="<<s2<<endl;
}
if(s1=s2)
{
cout<<"Two same roots x="<<s1<<endl;
}
else
{
cout<<"No real root"<<endl;
}
}
return 0;
}