1014冒泡排序文法推导

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