From 3b1774ccab8f3eef5f06db872e29274201b9f9aa Mon Sep 17 00:00:00 2001 From: flykhan Date: Mon, 19 Jun 2023 16:55:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=89=E7=9B=AE=E8=BF=90=E7=AE=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day6/d13.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 day6/d13.cpp 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