#include <iostream>
#include <math.h>
//大于0时,方程ax^2 + bx + c = 0有2个相同的解
void solver1(int a, int b, int c) {
double x1, x2, temp;
temp = b b - 4 a c;
x1 = (-b + sqrt(temp)) / (2 a);
x2 = (-b + sqrt(temp)) / (2 a);
std::cout << x1 << " " << x2 << std::endl;
}
//等于0时,方程ax^2 + bx + c = 0有2个相同的解
void solver2(int a, int b, int c) {
double x1, x2, temp;
x1 = -b / (2 a);
x2 = 0;
std::cout << x1 << " " << x2 << std::endl;
}
//小于0时,方程ax^2 + bx + c = 0无解
void solver3(int a, int b, int c) {
std::cout << "null" << std::endl;
}
int main()
{
int a = 0, b = 0, c = 0;
std::cout << "一元二次方程:" << "ax^2 + bx + c = 0" << std::endl;
std::cout << "请输入a, b, c:(用空格断开)" << std::endl;
std::cin >> a >> b >> c;
int delta = b b - 4 a c;
if(delta > 0) {
solver1(a, b, c);
} else if(delta == 0) {
solver2(a, b, c);
} else {
solver3(a, b, c);
}
return 0;
}