#54939: 二元一次


s310341@stu.ctsh.hcc.edu.tw (10613黃博思)


#include <iostream>
#include <cmath>
using namespace std;
int main ( ) {
    int a,b,c,x1,x2,ch,x;
    int bo;
    cin>>a;
    cin>>b;
    cin>>c;
    bo=b*b-4*a*c;
    x1=(-1*b+sqrt(bo))/(2*a);
    x2=(-1*b-sqrt(bo))/(2*a);
    x=x1;
    if ( bo > 0 ){
        cout<<"Two different roots ";
        if ( x1 > x2){
            cout<<"x1="<<x1<<" , ";
            cout<<"x2="<<x2;
        }
        else{
            ch=x1;
            x1=x2;
            x2=ch;
            cout<<"x1="<<x1<<" , ";
            cout<<"x2="<<x2;        
        }
    }
    else if ( bo < 0 ){
        cout<<"No real root";
    }
    else{
        cout<<"Two same roots ";
        cout<<"x="<<x;
    }
return 0;

}