输入三个整数,编写程序按次序输出最大数,最小数,中间数。c语言代码
时间: 2023-05-14 16:07:10 浏览: 135
以下是C语言代码:
```c
#include <stdio.h>
int main() {
int a, b, c, max, min, mid;
printf("请输入三个整数:\n");
scanf("%d %d %d", &a, &b, &c);
if (a > b) {
if (a > c) {
max = a;
if (b > c) {
mid = b;
min = c;
} else {
mid = c;
min = b;
}
} else {
max = c;
mid = a;
min = b;
}
} else {
if (b > c) {
max = b;
if (a > c) {
mid = a;
min = c;
} else {
mid = c;
min = a;
}
} else {
max = c;
mid = b;
min = a;
}
}
printf("最大数:%d\n", max);
printf("最小数:%d\n", min);
printf("中间数:%d\n", mid);
return 0;
}
```
希望能够帮到你!
阅读全文