标签:
1 public static void main(String[] args){ 2 int a[] = {34, 8, 64, 51, 32, 21}; 3 bubbleSort(a); 4 for (int i = 0; i < a.length; i++) { 5 System.out.print(a[i] + " "); 6 } 7 } 8 9 public static void bubbleSort(int[] a) { 10 for (int i = 0; i < a.length; i++) { 11 for (int j = i; j < a.length-i-1; j++) { 12 if (a[j] > a[j+1]) { 13 a[j] = a[j] ^ a[j+1]; 14 a[j+1] = a[j] ^ a[j+1]; 15 a[j] = a[j] ^ a[j+1]; 16 } 17 } 18 } 19 }
标签:
原文地址:http://www.cnblogs.com/daemonspirit/p/4682845.html