#29542: __紀錄


e3524167 (Kenlogin)


#include <iostream>

#include <math.h>

using namespace std;

int main()

{

int a, b, c;

int x1 = 0,x2 = 0;

int dis = 0;

 

cin >> a >> b >> c;

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

 

if (dis < 0)

{

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

}

else if (dis == 0)

{

x1 = x2 = (-b) / (2 * a);

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

}

else

{

x1 = (-b + sqrt(dis)) / (2 * a);

x2 = (-b - sqrt(dis)) / (2 * a);

cout << "Two different roots " << "x1=" << x1 << " " << ", " << "x2=" << x2 << endl;

}

}