From 6bfaa08e1ec77817f24098e52b497aa9b8fd8bf6 Mon Sep 17 00:00:00 2001 From: p1_cent Date: Thu, 5 Dec 2024 14:45:32 +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/Seat_2437/18897238.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 codes/Seat_2437/18897238.java diff --git a/codes/Seat_2437/18897238.java b/codes/Seat_2437/18897238.java new file mode 100644 index 00000000..96c49b19 --- /dev/null +++ b/codes/Seat_2437/18897238.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + +} //end -- Gitee From cec07689fb66753fc370911ba0520eb25be20e17 Mon Sep 17 00:00:00 2001 From: p1_cent Date: Thu, 5 Dec 2024 14:57:00 +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/Seat_2437/18897238.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codes/Seat_2437/18897238.java b/codes/Seat_2437/18897238.java index 96c49b19..1b423d83 100644 --- a/codes/Seat_2437/18897238.java +++ b/codes/Seat_2437/18897238.java @@ -15,5 +15,5 @@ public static void bubbleSort(int [] a, int n){ a[j + 1] = temp; } } - + } } //end -- Gitee