1 #include <stdio.h> 2 int main() 3 { 4 int a, b, c, d, t; 5 printf("请输入4个数:"); 6 scanf("%d%d%d%d", &a, &b, &c, &d); 7 if (a>b){ 8 t=a; a=b; b=t; 9 } 10 if (a>c){ 11 t=a; a=c; c=t; 12 } 13 if (a>d){ 14 t=a; a=d; d=t; 15 } 16 if (b>c){ 17 t=b; b=c; c=t; 18 } 19 if (b>d){ 20 t=b; b=d; d=t; 21 } 22 if (c>d){ 23 t=c; c=d; d=t; 24 } 25 printf("排序结果:%d %d %d %d", a, b, c, d); 26 return 0; 27 }
原文:https://www.cnblogs.com/xiuxiang0/p/11808869.html