From c513d36955a3dd2d3158765589268b46dba76266 Mon Sep 17 00:00:00 2001 From: 2Yuyuan <11901855+yuyuanbobo2@user.noreply.gitee.com> Date: Thu, 3 Nov 2022 03:33:18 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=BB=BA=202Yuyuan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/2Yuyuan/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 codes/2Yuyuan/.keep diff --git a/codes/2Yuyuan/.keep b/codes/2Yuyuan/.keep new file mode 100644 index 00000000..e69de29b -- Gitee From 57742f0992cb074b57937f4bd0494cb6a552a109 Mon Sep 17 00:00:00 2001 From: 2Yuyuan <11901855+yuyuanbobo2@user.noreply.gitee.com> Date: Thu, 3 Nov 2022 03:34:53 +0000 Subject: [PATCH 2/2] add codes/2Yuyuan/10041322.java. Signed-off-by: 2Yuyuan <11901855+yuyuanbobo2@user.noreply.gitee.com> --- codes/2Yuyuan/10041322.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 codes/2Yuyuan/10041322.java diff --git a/codes/2Yuyuan/10041322.java b/codes/2Yuyuan/10041322.java new file mode 100644 index 00000000..29d27043 --- /dev/null +++ b/codes/2Yuyuan/10041322.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * 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-1-i; j++) { + if (a[j] >= a[j+1]) { + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + System.out.print("冒泡排序的结果是: "); + for (int i : a) { + System.out.print(i + " "); + } +} //end \ No newline at end of file -- Gitee