
#include <iostream>
#include <iomanip>
#include <Cmath>
using namespace std;
class Equation
{
private:
double a, b, c;
public:
void init(int m , int n ,int q)
{
a = m;
b = n;
c = q;
}
void solve()
{
double s,x1,x2;
if(b*b - 4*a*c<0)
cout<<"There is no answer!"<<endl;
else
{
s = sqrt(b*b - 4*a*c);
x1 = (-b + s)/(2*a);
x2 = (-b - s)/(2*a);
cout <<"x1 = "<< x1 <<endl<<"x2 = "<< x2 << endl;
}
}
};
int main()
{
Equation c1;
int a, b,c;
cin>>a>>b>>c;
c1.init(a, b, c);
c1.solve();
return 0;
}



by: 发表于:2017-09-01 09:52:55 顶(2) | 踩(0) 回复
??
回复评论