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

排序算法复习-冒泡

时间:2017-11-04 13:46:17      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:out   temp   sys   i+1   for   bsp   static   oid   nbsp   

冒泡排序

public class BubleSort {
 public static void Sort(int[] array){
  for(int i=0;i<array.length;i++){
   for(int j=i+1;j<array.length;j++){
    if(array[i]>array[j]){
     int temp=array[i];
     array[i]=array[j];
     array[j]=temp;
    }
   }
  }
 }
 public static void main(){
  int array[]={5, 69, 12, 3, 56, 789, 2, 5648, 23};
  Sort(array);
  for(int i:array){
   System.out.printf("\t"+i);
  }
 }
}

 

排序算法复习-冒泡

标签:out   temp   sys   i+1   for   bsp   static   oid   nbsp   

原文地址:http://www.cnblogs.com/styz/p/7782647.html

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