From 707cbda719034807b27d7d654028052722d0f083 Mon Sep 17 00:00:00 2001 From: BuddyZhang1 Date: Thu, 20 Jun 2024 17:44:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=86=92=E6=B3=A1=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/BuddyZhang1/17122148.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 codes/BuddyZhang1/17122148.java diff --git a/codes/BuddyZhang1/17122148.java b/codes/BuddyZhang1/17122148.java new file mode 100644 index 000000000..2b4217cd1 --- /dev/null +++ b/codes/BuddyZhang1/17122148.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + 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