冒泡排序

 1 #include <stdio.h>
 2 int main(void)
 3 {
 4     int i, j, t, a[11];
 5 
 6     printf("please input 10 numbers:
");
 7 
 8     for(i = 1;i < 11;i++)
 9         scanf("%d", &a[i]);
10 
11     for(i = 1;i < 10;i++)
12         for(j = 1;j < 11 - i;j++)
13             if(a[j] > a[j+1])
14             {
15                 t = a[j];
16                 a[j] = a[j+1];
17                 a[j+1] = t;
18             }
19 
20     printf("the sorted numbers:
");
21 
22     for(i = 1;i <= 10;i++)
23         printf("%5d", a[i]);
24 
25 }
原文地址:https://www.cnblogs.com/junsircoding/p/bubblesort.html