#include <iostream> #include<iomanip> #include<cmath> using namespace std; int main() { float a = 0; //定义a,b,c float b = 0; float c = 0; while (cin >> a >> b >> c) { //多组输入 if (a == 0) { //判断a是否为0 cout << "Not quadratic equation" << endl; } else { float delta = b * b - 4 * a * c; if (delta == 0) { float x; if (b == 0 && a > 0) { x = b / (2 * a); } else { x = (-b) / (2 * a); } cout << fixed << setprecision(2) << "x1=x2=" << x << endl; } else if (delta > 0) { float x1 = ((-b) - sqrt(delta)) / (2 * a); float x2 = ((-b) + sqrt(delta)) / (2 * a); cout << fixed << setprecision(2) << "x1=" << x1 << ";" << "x2=" << x2 << endl; } else if (delta < 0) { float shi = (-b) / (2 * a); float xu = sqrt(-delta) / (2 * a); if (a > 0) { cout << fixed << setprecision(2) << "x1=" << shi << "-" << xu << "i;x2=" << shi << "+" << xu << "i" << endl; } else if (a < 0) { cout << fixed << setprecision(2) << "x1=" << shi << "+" << xu << "i;x2=" << shi << "-" << xu << "i" << endl; } } } } return 0; }