使用b平-4ac判斷式
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
int t,x1,x2;
t=(b*b)-(4*a*c);
x1=(-b+sqrt(b*b-4*a*c))/(2*a);
x2=(-b-sqrt(b*b-4*a*c))/(2*a);
if (t<0){
cout<<"No real root";
}
else if (t==0){
cout<<"Two same roots x="<<x1;
}
else{
cout<<"Two different roots x1="<<x1<<" , x2="<<x2;
}
}