diff --git a/day6/d13.cpp b/day6/d13.cpp new file mode 100644 index 0000000..d5d2547 --- /dev/null +++ b/day6/d13.cpp @@ -0,0 +1,21 @@ +// 三目运算符 +// 从键盘输入三个整数,输出最大或最小的那个数 +#include +#include + +using namespace std; + +int main() +{ + int x, y, z; + cout << "请输入三个整数: "; + cin >> x >> y >> z; + + int max = x > y ? (x > z ? x : z) : (y > z ? y : z); + cout << "最大值为: " << max << endl; + + int min = x < y ? (x < z ? x : z) : (y < z ? y : z); + cout << "最小值为: " << min << endl; + + return 0; +} \ No newline at end of file