C语言中四个数比较大小问题


 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 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM