From 6ba229929ac09213093ee9cfbafc33292cb234b5 Mon Sep 17 00:00:00 2001 From: A_Words <9553472+a-words@user.noreply.gitee.com> Date: Tue, 3 Dec 2024 20:38:42 +0800 Subject: [PATCH 1/5] =?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/A_Words/18888103.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 codes/A_Words/18888103.java diff --git a/codes/A_Words/18888103.java b/codes/A_Words/18888103.java new file mode 100644 index 00000000..0694ae6c --- /dev/null +++ b/codes/A_Words/18888103.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + //你的代码,使无序数组a变得有序 + for (i = 0, arr.length - 1, i++){ + for (j = 0, j = arr.length - 1 - i, j++){ + if (arr[j]>arr[j+1]){ + tmp = arr[j]; + arr[j] = arr[j+1]; + arr[j+1] = tmp; + } + } + } +} //end -- Gitee From ffd860919c5216934ead1109be7233cd69b0f755 Mon Sep 17 00:00:00 2001 From: A_Words <9553472+a-words@user.noreply.gitee.com> Date: Tue, 3 Dec 2024 20:49:27 +0800 Subject: [PATCH 2/5] =?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/A_Words/18888103.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/codes/A_Words/18888103.java b/codes/A_Words/18888103.java index 0694ae6c..e8aa8213 100644 --- a/codes/A_Words/18888103.java +++ b/codes/A_Words/18888103.java @@ -6,12 +6,12 @@ */ public static void bubbleSort(int [] a, int n){ //你的代码,使无序数组a变得有序 - for (i = 0, arr.length - 1, i++){ - for (j = 0, j = arr.length - 1 - i, j++){ - if (arr[j]>arr[j+1]){ - tmp = arr[j]; - arr[j] = arr[j+1]; - arr[j+1] = tmp; + for (int i = 0, i < n - 1, i++){ + for (int j = 0, j = n - 1 - i, j++){ + if (a[j]>a[j+1]){ + tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; } } } -- Gitee From fbe05e0c79202b46d05dacf00df1cdc6dee19553 Mon Sep 17 00:00:00 2001 From: A_Words <9553472+a-words@user.noreply.gitee.com> Date: Tue, 3 Dec 2024 20:57:36 +0800 Subject: [PATCH 3/5] =?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/A_Words/18888103.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/A_Words/18888103.java b/codes/A_Words/18888103.java index e8aa8213..1f103fc1 100644 --- a/codes/A_Words/18888103.java +++ b/codes/A_Words/18888103.java @@ -7,7 +7,7 @@ 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++){ + for (int j = 0, j < n - 1 - i, j++){ if (a[j]>a[j+1]){ tmp = a[j]; a[j] = a[j+1]; -- Gitee From cbfb0d8747b5318699e8d7c89c9793972007fb5e Mon Sep 17 00:00:00 2001 From: A_Words <9553472+a-words@user.noreply.gitee.com> Date: Tue, 3 Dec 2024 21:00:46 +0800 Subject: [PATCH 4/5] =?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/A_Words/18888103.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codes/A_Words/18888103.java b/codes/A_Words/18888103.java index 1f103fc1..f33eb53b 100644 --- a/codes/A_Words/18888103.java +++ b/codes/A_Words/18888103.java @@ -6,8 +6,8 @@ */ 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++){ + for (int i = 0; i < n - 1; i++){ + for (int j = 0; j < n - 1 - i; j++){ if (a[j]>a[j+1]){ tmp = a[j]; a[j] = a[j+1]; -- Gitee From 7477bb39a45a91cfa03505ceb1b22501b067e879 Mon Sep 17 00:00:00 2001 From: A_Words <9553472+a-words@user.noreply.gitee.com> Date: Tue, 3 Dec 2024 21:03:13 +0800 Subject: [PATCH 5/5] =?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/A_Words/18888103.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codes/A_Words/18888103.java b/codes/A_Words/18888103.java index f33eb53b..c10772c5 100644 --- a/codes/A_Words/18888103.java +++ b/codes/A_Words/18888103.java @@ -8,8 +8,8 @@ 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]){ - tmp = a[j]; + if (a[j] > a[j+1]){ + int tmp = a[j]; a[j] = a[j+1]; a[j+1] = tmp; } -- Gitee