用c++实现输入三个正整数,按从大到小排序输出
时间: 2024-05-14 19:12:51 浏览: 24
输入三个整数,按由大到小输出.c
```c
#include <stdio.h>
int main() {
int a, b, c, temp;
printf("请输入三个正整数:\n");
scanf("%d%d%d", &a, &b, &c);
if (a < b) {
temp = a;
a = b;
b = temp;
}
if (a < c) {
temp = a;
a = c;
c = temp;
}
if (b < c) {
temp = b;
b = c;
c = temp;
}
printf("从大到小排序后的结果为:%d %d %d\n", a, b, c);
return 0;
}
```
阅读全文