使用逻辑运算符实现以下条件:输入三个数,输出其中最大的数。

This commit is contained in:
flykhan 2023-06-20 08:51:57 +08:00
parent 84fb470ed7
commit a7d39aa736
1 changed files with 15 additions and 0 deletions

15
day6/homework/h8.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
cout << "请输入三个数: ";
cin >> a >> b >> c;
int max = a > b ? (a > c ? a : c) : (b > c ? b : c);
cout << "其中最大的数是: " << max << endl;
return 0;
}