使用逻辑运算符实现以下条件:输入三个数,输出其中最大的数。
This commit is contained in:
parent
84fb470ed7
commit
a7d39aa736
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue