<<  < 2014 - >  >>
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30




void bubble sort(int a[],int n){

      int  temp

   for(i=n-1,change=ture;i>=1&&chang;--i){

        change=false;

        for(j=0;j<i;++j){

            if(a[j]>a[j+1]){  //每次从前面把最大的数放到当前排列队的末尾,长度减一

                    temp=a[j];

                   a[j]=a[j+1];

                   a[j+1]=temp;

                 change=true;

            }

     }

                 

发表评论:
天涯博客欢迎您!