编程:通过键盘输入任意3个整数存入变量a,b,c中,要求按由小到大的顺序将数字重新存储于变量a,b,c中并输出。c语言
时间: 2023-05-23 21:02:28 浏览: 95
可以这样写代码:
```
#include <stdio.h>
int main() {
int a, b, c, temp;
printf("Please input three integers: ");
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("The sorted integers are: %d %d %d", a, b, c);
return 0;
}
```
输入三个数字后,代码会将它们按从小到大的顺序排列,并输出结果。