码迷,mamicode.com
首页 > 编程语言 > 详细

冒泡排序

时间:2016-06-04 13:30:12      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:

public class bubbleSort {  
public  bubbleSort(){  
     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=0;  
    for(int i=a.length-1;i>1;i--){  
        for(int j=0;j<i;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.println(a[i]);     
}  
}  

 

冒泡排序

标签:

原文地址:http://www.cnblogs.com/artcode007/p/5558580.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!