From 6047697ef06a67162a2a33c1f1af64699698fbcb Mon Sep 17 00:00:00 2001 From: li-yuhang-is-okay <1269771320@qq.com> Date: Sat, 7 Dec 2024 10:54:04 +0800 Subject: [PATCH 1/3] =?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/a1269771320/18927925.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 codes/a1269771320/18927925.java diff --git a/codes/a1269771320/18927925.java b/codes/a1269771320/18927925.java new file mode 100644 index 000000000..fb6f500be --- /dev/null +++ b/codes/a1269771320/18927925.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;ia[j+1]){ + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } + }//end -- Gitee From 7931ed9d922ec4d95ab1dafb74c7fdffeb0dfc02 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:42:36 +0000 Subject: [PATCH 2/3] 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 f109a46f4d435d7075e046eacb68aa968259aa49 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 04:21:56 +0000 Subject: [PATCH 3/3] 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 | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/codes/a1269771320/18927925.java b/codes/a1269771320/18927925.java index 300758a9b..88de9aa65 100644 --- a/codes/a1269771320/18927925.java +++ b/codes/a1269771320/18927925.java @@ -3,16 +3,16 @@ * 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