package com.jmmq.load.jim.algorithm;
/**
* 冒泡排序
*/
public class BubblingSortPrc {
public static void main(String[] args) {
int[] c = {5,8,9,5,55,77,13,92,55,0,-5,56,23};
c = bubblingSort(c);
for(int i=0;i<c.length;i++) {
System.out.print(c[i] + " ");
}
}
/**
*
* @param c
*/
public static int[] bubblingSort(int [] c){
for(int i=1; i< c.length-1; i++){
for(int j=c.length-1;j>=i;j--){
// 当前元素比下一个元素小,大的下沉,小的上浮
if(c[j] < c[j-1]){
int temp = c[j-1];
c[j-1] = c[j];
c[j] = temp;
}
}
}
return c;
}
}
-5 0 5 5 8 9 13 23 55 55 56 77 92