冒泡排序

package com.wyc.cn;
/**
 * 冒泡排序
 * @author buyi
 * @version 2015-09-18
 * **/
public class BubboSort {
    public static void main(String[] args) {
        int a[]={49,38,65,97,76,13,27,49,78,34,12,64,5,4,62,99,98,54,56,17,18,23,34,15,35,25,53,51};
        int temp ;
        for(int i=0;i<a.length-i;i++) {
            for(int j=0;j<a.length-i-1;j++) {
                if(a[j] < a[j+1]) {
                    temp = a[j] ;
                    a[j] = a[j+1] ;
                    a[j+1] = temp ;
                }
            }
        }
        
        //输出排序数组
        for(int i=0;i<a.length;i++) {
            System.out.print(a[i]+",");
        }
    }
}

posted on 2015-09-21 10:38  javawg  阅读(158)  评论(0)    收藏  举报

导航