From 0a81162be50fd613608d84bc7cd7dbd686c82333 Mon Sep 17 00:00:00 2001 From: Acacia-YX <326804139@qq.com> Date: Tue, 22 Apr 2025 09:56:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/foxglove/20291402.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 codes/foxglove/20291402.java diff --git a/codes/foxglove/20291402.java b/codes/foxglove/20291402.java new file mode 100644 index 000000000..52e509ff7 --- /dev/null +++ b/codes/foxglove/20291402.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - 1 - i; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end -- Gitee From d770d0c84dc0e327a92aaca9bc450cd21da61fca Mon Sep 17 00:00:00 2001 From: Acacia-YX <326804139@qq.com> Date: Tue, 22 Apr 2025 09:59:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/foxglove/20291402.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codes/foxglove/20291402.java b/codes/foxglove/20291402.java index 52e509ff7..fec655705 100644 --- a/codes/foxglove/20291402.java +++ b/codes/foxglove/20291402.java @@ -6,9 +6,9 @@ */ public static void bubbleSort(int [] a, int n){ // 你的代码,使无序数组 a 变得有序 - for (int i = 0; i < n - 1; i++) { - for (int j = 0; j < n - 1 - i; j++) { - if (a[j] > a[j + 1]) { + for (int i = 0; i < n - 1; i++){ + for (int j = 0; j < n - 1 - i; j++){ + if (a[j] > a[j + 1]){ int temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; -- Gitee