#13271: C++本題參考(有排版)


monero778176 (堃)


#include<iostream>
#include<cmath>


using namespace std;

    
int main(void)
{


int a,b,c;
int x1,x2;
while(cin>>a>>b>>c)
{


int judge = b*b-4*a*c;
float i = sqrt(judge);
x1 = (-b+i)/(2*a);
x2 = (-b-i)/(2*a);

if(judge<0)
{


cout<<"No real root"<<endl;


}
if(judge==0)
{


cout<<"Two same roots x="<<x1<<endl;


}
if(judge>0)
{


if(x1!=x2 && x1>x2)
{
cout<<"Two different roots x1="<<x1<<" , x2="<<x2<<endl;
}
if(x1!=x2 && x1<x2)
{
cout<<"Two different roots x1="<<x2<<" , x2="<<x1<<endl;
}


}


}


return 0;


}