三个数由小到大排序


1
#include <stdio.h> 2 3 int main(void) 4 { 5 int a,b,c; 6 int temp; 7 printf("please input a b c "); 8 scanf("%d %d %d",&a,&b,&c); 9 10 if(a>b) 11 { 12 temp=a; 13 a=b; 14 b=temp; 15 16 } 17 if(a>c) 18 { 19 temp=c; 20 c=a; 21 a=temp; 22 } 23 if(b>c) 24 { 25 temp=b; 26 c=b; 27 b=temp; 28 } 29 30 printf("%d %d %d",a,b,c); 31 32 return 0; 33 }

      属于交换类排序但非冒泡型。运行结果如下:

      

原文地址:https://www.cnblogs.com/xiaoying1245970347/p/3702989.html