diff --git a/codes/s18893442896/16477528.java b/codes/s18893442896/16477528.java new file mode 100644 index 0000000000000000000000000000000000000000..4324a239990b0166d31b00f71e85ef397ec6b658 --- /dev/null +++ b/codes/s18893442896/16477528.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + if (array == null || n <= 1) { + return; + } + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - i - 1; j++) { + if (array[j] > array[j + 1]) { + int temp = array[j]; + array[j] = array[j + 1]; + array[j + 1] = temp; + } + } + } + for (int num : array) { + System.out.print(num + " "); + } +}