#include<iostream>
using namespace std;
#include<math.h>
int main()
{
double a, b, c,outcome;
cout << "请输入二元一次方程的系数a,b,c" << endl;
cin >> a;
cin >> b;
cin >> c;
cout << "你输入的函数是:" << a << "x*x" << "+" << b << "x" << "+" << c << "=0" << endl;
if (a == 0)
{
if (b == 0)
{
cout << "输入错误" << endl;
}
else
{
cout << "函数根为:" << -c / b << endl;
}
}
else
{
double T = b * b - 4 * a * c;
if (T == 0)
{
cout << "函数的根为:" << "x1=x2=" << -b / (2 * a) << endl;
}
else if (T > 0)
{
cout << "函数根为:" << "x1=" << (-b + sqrt(T)) / (2 * a) << endl;
cout << "x2=" << (-b -sqrt(T)) / (2 * a) << endl;
}
else
{
cout << "无实根" << endl;
}
}
}
11-09
5297
06-22
526
07-31
3462