#include <iostream>
using namespace std;
int main4_1_5()
{
//三目运算符
int a = 10;
int b = 5;
int c = 0;
cout << "a";
cin >> a;
cout << "b";
cin >> b;
c = a > b ? a : b;//真取a,否者返回b
//返回的是变量,可以赋值操作
a > b ? a : b = 100;
//即:a=100
system("pause");
return 0;
}
# 4.1.4if案例
#include <iostream>
using namespace std;
int main4_15()
{
int a = 0;
int b = 0;
int c = 0;
cout << "a";
cin >> a;
cout << "b";
cin >> b;
cout << "c";
cin >> c;
if (a >= b)
{
if (a >= c)
{
cout << "a_zhong" << endl;
}
else
{
cout << "c_zhong" << endl;
}
}
else
{
if (b >= c)
{
cout << "b_zhong" << endl;
}
else
{
cout << "c_zhong" << endl;
}
}
system("pause");
return 0;
}