From 9bfe5df65993924c2eb309b6ac45aa2ee316bd25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9B=A8=E8=88=AAok?= <15210815+li-yuhang-is-okay@user.noreply.gitee.com> Date: Sat, 7 Dec 2024 03:49:07 +0000 Subject: [PATCH 1/2] update codes/a1269771320/18927925.java. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李雨航ok <15210815+li-yuhang-is-okay@user.noreply.gitee.com> --- codes/a1269771320/18927925.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/a1269771320/18927925.java b/codes/a1269771320/18927925.java index fb6f500be..300758a9b 100644 --- a/codes/a1269771320/18927925.java +++ b/codes/a1269771320/18927925.java @@ -6,7 +6,7 @@ * / public static void bubbleSort(int[] a,int n){ // 你的代码,,使无序数组a变得有序 - for(int i=0;ia[j+1]){ int temp=a[j]; -- Gitee From febd5be0a00c09f3ef5c3042e7c0c221f35ecf5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9B=A8=E8=88=AAok?= <15210815+li-yuhang-is-okay@user.noreply.gitee.com> Date: Sat, 7 Dec 2024 03:55:22 +0000 Subject: [PATCH 2/2] update codes/a1269771320/18927925.java. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李雨航ok <15210815+li-yuhang-is-okay@user.noreply.gitee.com> --- codes/a1269771320/18927925.java | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/codes/a1269771320/18927925.java b/codes/a1269771320/18927925.java index 300758a9b..476d2b115 100644 --- a/codes/a1269771320/18927925.java +++ b/codes/a1269771320/18927925.java @@ -3,16 +3,17 @@ * aa bb cc * @param a 待排序的数组 * @param n 待排序的数组长度 - * / - public static void bubbleSort(int[] a,int n){ - // 你的代码,,使无序数组a变得有序 - for(int i=0;ia[j+1]){ - int temp=a[j]; - a[j]=a[j+1]; - a[j+1]=temp; - } - } - } - }//end + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file -- Gitee