diff --git a/codes/piero_choi/19955133.java b/codes/piero_choi/19955133.java new file mode 100644 index 0000000000000000000000000000000000000000..ca591876bf4567d99710d89f5d09b26f45e920af --- /dev/null +++ b/codes/piero_choi/19955133.java @@ -0,0 +1,34 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + + bubbleSort(a, 0, n-1); +} //end + +public static void bubbleSort(int [] a, int low, int high) { + + if (low >= high) return; + + int pilot = a[high]; + int i = low; + + for (int j = low; j < high; j++) { + if (a[j] < pilot) { + int tmp = a[j]; + a[j] = a[i]; + a[i] = tmp; + i++; + } + } + + a[high] = a[i]; + a[i] = pilot; + + bubbleSort(a, low, i-1); + bubbleSort(a, i+1, high); + +}