習題:輸入a,b,c三個數,並將a,b,c三個數由大至小輸出。

 1 /* 輸入a,b,c三個整數,將a,b,c 由大到小輸出*/
 2 #include<stdio.h>
 3 main()
 4 {
 5     int a,b,c,k;
 6     printf("please input three integer number : \n");
 7     scanf("%d%d%d",&a,&b,&c);
 8     if (a<b)
 9     {
10         k=a;
11         a=b;
12         b=k;
13     }
14     if (a<c)
15     {
16         k=a;
17         a=c;
18         c=k;
19     }
20     if (b<c)
21     {
22         k=b;
23         b=c;
24         c=k;
25     }
26     printf("These numbers from large to small are follows :\n");
27     printf("a=%d\nb=%d\nc=%d\n",a,b,c);
28     return 0;
29 }
相關文章
相關標籤/搜索