#include <iostream>
#include <cmath>
using namespace std;
double jie(double a, double b, double c);
int main()
{
cout << "begining" << endl;
double a, b, c, aa;
cout << "Pleasse input a, b, c:";
cin >> a >> b >> c;
try
{
aa = sqrt(jie(a, b, c));
cout << "x1=" << (-b + aa) / (2 * a) << endl;
cout << "x2=" << (-b - aa) / (2 * a) << endl;
}
catch (double)
{
cout << "a=" << a << endl << "this is not fit for a" << endl;
}
catch (const char *s)
{
cout << s << endl << "this is not fit for a,b,c" << endl;
}
catch (...)
{
cout << "all error is not good" << endl;
}
return 0;
}
double jie(double a, double b,double c)
{
double disc;
if (a == 0) throw 0;
else if ((disc = b * b - 4 * a * c) < 0) throw "b * b - 4 * a *c < 0";
else return disc;
}