java冒泡排序(从小到大)

时间:2014-01-14 19:43:38   收藏:0   阅读:588
bubuko.com,布布扣
 1 public class Sort{
 2      public static void main(String[] args){
 3          int a[] = {6,37,26,12,58,10,22,43};
 4          for(int i=0;i<a.length-1;i++){
 5               for(int j=0;j<a.length-i-1;j++){
 6                   if(a[j]>a[j+1]){
 7                      int temp = a[j];
 8                      a[j]= a[j+1];
 9                      a[j+1] = temp;
10                   }
11               } 
12          }
13          for(int r=0;r<a.length;r++){
14              System.out.print(a[r]+"\t");
15          }
16     }
17 }
bubuko.com,布布扣

原文:http://www.cnblogs.com/wuhenvhai/p/3512738.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!