三元表达式语法为
条件表达式? 表达式1:表达式2;
此题目要求对比三个数的最大值,代码可以这样写
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a;
cin >> b;
cin >> c;
// write your code here......
int max;
max = a > b ? a:b;
max = max > c ? max:c;
cout << max;
return 0;
}

京公网安备 11010502036488号