From 0280f0cd203354645bf0120a3fdc02fe6dadee64 Mon Sep 17 00:00:00 2001 From: anolis-copy Date: Thu, 22 Sep 2022 11:13:25 +0000 Subject: [PATCH 1/4] add codes/shankailun10/9682326.java. Signed-off-by: anolis-copy --- codes/shankailun10/9682326.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 codes/shankailun10/9682326.java diff --git a/codes/shankailun10/9682326.java b/codes/shankailun10/9682326.java new file mode 100644 index 00000000..d616feaa --- /dev/null +++ b/codes/shankailun10/9682326.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for(int i =0 ; iarr[j+1]) { + int temp = arr[j]; + + arr[j]=arr[j+1]; + + arr[j+1]=temp; + } + } + } +} //end \ No newline at end of file -- Gitee From 5dc2f2fcb35bda70adbc2c9bfe874509f983481c Mon Sep 17 00:00:00 2001 From: anolis-copy Date: Thu, 22 Sep 2022 12:43:16 +0000 Subject: [PATCH 2/4] add codes/shankailun10/9638206.java. Signed-off-by: anolis-copy --- codes/shankailun10/9638206.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 codes/shankailun10/9638206.java diff --git a/codes/shankailun10/9638206.java b/codes/shankailun10/9638206.java new file mode 100644 index 00000000..d616feaa --- /dev/null +++ b/codes/shankailun10/9638206.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for(int i =0 ; iarr[j+1]) { + int temp = arr[j]; + + arr[j]=arr[j+1]; + + arr[j+1]=temp; + } + } + } +} //end \ No newline at end of file -- Gitee From 628e8a22807e942144ef8f785fa57f034d2c070f Mon Sep 17 00:00:00 2001 From: anolis-copy Date: Thu, 22 Sep 2022 12:43:56 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20code?= =?UTF-8?q?s/shankailun10/9682326.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/shankailun10/9682326.java | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 codes/shankailun10/9682326.java diff --git a/codes/shankailun10/9682326.java b/codes/shankailun10/9682326.java deleted file mode 100644 index d616feaa..00000000 --- a/codes/shankailun10/9682326.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * 冒泡排序函数 - * aa bb cc - * @param a 待排序的数组 - * @param n 待排序的数组长度 - */ -public static void bubbleSort(int [] a, int n){ - for(int i =0 ; iarr[j+1]) { - int temp = arr[j]; - - arr[j]=arr[j+1]; - - arr[j+1]=temp; - } - } - } -} //end \ No newline at end of file -- Gitee From b111cd73df6315e488d0903c16b18440673d6b2e Mon Sep 17 00:00:00 2001 From: anolis-copy Date: Thu, 22 Sep 2022 12:45:47 +0000 Subject: [PATCH 4/4] update codes/shankailun10/9638206.java. Signed-off-by: anolis-copy --- codes/shankailun10/9638206.java | 35 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/codes/shankailun10/9638206.java b/codes/shankailun10/9638206.java index d616feaa..4dbc2659 100644 --- a/codes/shankailun10/9638206.java +++ b/codes/shankailun10/9638206.java @@ -1,21 +1,22 @@ /** - * 冒泡排序函数 - * aa bb cc - * @param a 待排序的数组 - * @param n 待排序的数组长度 - */ -public static void bubbleSort(int [] a, int n){ - for(int i =0 ; iarr[j+1]) { - int temp = arr[j]; - - arr[j]=arr[j+1]; - - arr[j+1]=temp; + * 冒泡排序函数 + * aa bb cc + * + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + // 你的代码,使无序数组 a 变得有序 + int i, j; + for (i = 0; i < n; i++) {//表示n次排序过程。 + for (j = 1; j < n - i; j++) { + if (a[j - 1] > a[j]) {//前面的数字大于后面的数字就交换 + //交换a[j-1]和a[j] + int temp; + temp = a[j - 1]; + a[j - 1] = a[j]; + a[j] = temp; } - } } + } } //end \ No newline at end of file -- Gitee