输入三个整数按从大到小排序
时间: 2023-05-20 21:07:00 浏览: 48
可以使用以下代码实现:
```
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
if (a >= b && a >= c) {
if (b >= c) {
cout << a << " " << b << " " << c << endl;
} else {
cout << a << " " << c << " " << b << endl;
}
} else if (b >= a && b >= c) {
if (a >= c) {
cout << b << " " << a << " " << c << endl;
} else {
cout << b << " " << c << " " << a << endl;
}
} else {
if (a >= b) {
cout << c << " " << a << " " << b << endl;
} else {
cout << c << " " << b << " " << a << endl;
}
}
return 0;
}
```
这段代码可以实现输入三个整数,然后按从大到小的顺序输出。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)