代码
//关系运算
#include<iostream>
using namespace std;
int main()
{
double a, b, c; //定义双精度
bool f,g,h;
cin >> a >> b >> c;
//法一:直接判断“德尔塔”关系的真假,真输出1,假输出0
cout << (b*b - 4 * a*c == 0) << endl;
cout << (b*b - 4 * a*c > 0) << endl;
cout << (b*b - 4 * a*c < 0) << endl << endl;
//法二:将判断结果赋予布尔函数再输出
f = (b * b - 4 * a*c == 0);
g = (b*b - 4 * a*c > 0);
h = (b*b - 4 * a*c < 0);
cout << f << endl;
cout << g << endl;
cout << h << endl;
system("pause");
return 0;
}
程序
知识点