From ec92d6b1c1dd93fbab18591f3b8c510ab607a9a8 Mon Sep 17 00:00:00 2001 From: csjhero <18810388048@163.com> Date: Wed, 16 Oct 2024 16:35:42 +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/TechOS/18361562.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 codes/TechOS/18361562.java diff --git a/codes/TechOS/18361562.java b/codes/TechOS/18361562.java new file mode 100644 index 000000000..25297d83c --- /dev/null +++ b/codes/TechOS/18361562.java @@ -0,0 +1,12 @@ +public static void bubbleSort((int[] arr){ + int n= arr.length; + for (int i= 0; iarr[j+1]){ + int temp = arr[j]; + arr[j] = arr[j+1]; + arr[j+1] = temp; + } + } + } +} -- Gitee From 32ba844ab61458ab66189840b4eda457497695d9 Mon Sep 17 00:00:00 2001 From: csjhero <18810388048@163.com> Date: Wed, 16 Oct 2024 16:51:25 +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/TechOS/18361562.java | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/codes/TechOS/18361562.java b/codes/TechOS/18361562.java index 25297d83c..a4cc45a95 100644 --- a/codes/TechOS/18361562.java +++ b/codes/TechOS/18361562.java @@ -1,12 +1,14 @@ -public static void bubbleSort((int[] arr){ - int n= arr.length; - for (int i= 0; iarr[j+1]){ - int temp = arr[j]; - arr[j] = arr[j+1]; - arr[j+1] = temp; - } - } - } +public class BubbleSort { + public static void bubbleSort(int[] arr) { + int n = arr.length; + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - i - 1; j++) { + if (arr[j] > arr[j + 1]) { + int temp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = temp; + } + } + } + } } -- Gitee