1 /** 2 * 冒泡排序 3 * @param a 4 * @date 2016-10-8 5 * @author shaobn 6 */ 7 public static void bubbleSort(int[] a){ 8 int temp = 0; 9 for(int i = 1;i<a.length;i++){ 10 for(int j = 0;j<a.length-i;j++){ 11 if(a[j]>a[j+1]){ 12 temp = a[j]; 13 a[j] = a[j+1]; 14 a[j+1] = temp; 15 } 16 } 17 } 18 for(int num:a){ 19 System.out.println(num); 20 } 21 }