From 34c7aca1df42cb1393dab4cbc46d6eb9ae4088d9 Mon Sep 17 00:00:00 2001 From: yymyhhh <3418918637@qq.com> Date: Tue, 9 Apr 2024 16:05:06 +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 --- 15824820.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 15824820.java diff --git a/15824820.java b/15824820.java new file mode 100644 index 000000000..53e13500a --- /dev/null +++ b/15824820.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序 + * + * @param a 待排序的数组 + * @param n 数组的长度 + */ + public static void bubbleSort1(int[] a, int n) { + int i, j; + + for (i = n - 1; i > 0; i--) { + // 将a[0...i]中最大的数据放在末尾 + for (j = 0; j < i; j++) { + + if (a[j] > a[j + 1]) { + // 交换a[j]和a[j+1] + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + } -- Gitee From 1592bacf6f4effdda40d2c5c0837cc2ee2adfefa Mon Sep 17 00:00:00 2001 From: yymyhhh <14279525+yymyhhh@user.noreply.gitee.com> Date: Tue, 9 Apr 2024 08:32:39 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Revert=20"=E6=B7=BB=E5=8A=A0=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E4=BB=A3=E7=A0=81"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 34c7aca1df42cb1393dab4cbc46d6eb9ae4088d9. --- 15824820.java | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 15824820.java diff --git a/15824820.java b/15824820.java deleted file mode 100644 index 53e13500a..000000000 --- a/15824820.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 冒泡排序 - * - * @param a 待排序的数组 - * @param n 数组的长度 - */ - public static void bubbleSort1(int[] a, int n) { - int i, j; - - for (i = n - 1; i > 0; i--) { - // 将a[0...i]中最大的数据放在末尾 - for (j = 0; j < i; j++) { - - if (a[j] > a[j + 1]) { - // 交换a[j]和a[j+1] - int tmp = a[j]; - a[j] = a[j + 1]; - a[j + 1] = tmp; - } - } - } - } -- Gitee