答案:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double a, b, c;
double t;
void fun_1(double,double,double);
void fun_2();
void fun_3(double,double);
cout << "please enter:a ,b ,c :" << endl;
cin >> a >> b >> c;
t = b * b- 4 * a * c;
if (t > 0)
{
fun_1(a,b,t);
}
else if (t == 0)
{
fun_3(a,b);
}
else if (t < 0)
{
fun_2();
}
return 0;
}
void fun_1(double a,double b,double t)
{
double x1, x2;
x1 = (sqrt(t) - b) / (2 * a);
x2 = (- sqrt(t) - b) / (2 * a);
cout << "the Desorption equatio is:x1=" << x1 << " x2=" << x2 << endl;
}
void fun_2()
{
cout << "The equation has no solution!" << endl;
}
void fun_3(double a,double b)
{
double x;
x = (-b) / (2 * a);
cout << "the Desorption equatio is:x=" << x << endl;
}