From 612457be35ef37af4c20560883465ac9136370a0 Mon Sep 17 00:00:00 2001 From: ywyw22 Date: Tue, 18 Oct 2022 18:15:41 +0800 Subject: [PATCH 1/5] add bubble sort code --- codes/ywyw22/BubbleSort.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 codes/ywyw22/BubbleSort.java diff --git a/codes/ywyw22/BubbleSort.java b/codes/ywyw22/BubbleSort.java new file mode 100644 index 00000000..e24207ff --- /dev/null +++ b/codes/ywyw22/BubbleSort.java @@ -0,0 +1,22 @@ +import java.util.Arrays; + +public class BubbleSort { + public static void main(String args[]) { + int [] values = {4, 5 ,6 ,8 ,9 ,10}; + bubbleSort(values); + System.out.println(Arrays.toString(values)); + } + + public static void bubbleSort(int[] values) { + int temp; + for (int i = 0; i < values.length; i++) { + for (int j = 0; j < values.length - 1 - i; j++) { + if (values[j] > values[j + 1]) { + temp = values[j]; + values[j] = values[j + 1]; + values[j + 1] = temp; + } + } + } + } +} -- Gitee From cb06a4c1283af0a1a7a4351d4d6e8a6ae90b2493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=B0=E8=AF=BA=E6=96=AF?= Date: Tue, 18 Oct 2022 10:19:25 +0000 Subject: [PATCH 2/5] rename codes/ywyw22/BubbleSort.java to codes/ywyw22/9682142.java. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杰诺斯 --- codes/ywyw22/{BubbleSort.java => 9682142.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename codes/ywyw22/{BubbleSort.java => 9682142.java} (95%) diff --git a/codes/ywyw22/BubbleSort.java b/codes/ywyw22/9682142.java similarity index 95% rename from codes/ywyw22/BubbleSort.java rename to codes/ywyw22/9682142.java index e24207ff..8b96c2c1 100644 --- a/codes/ywyw22/BubbleSort.java +++ b/codes/ywyw22/9682142.java @@ -1,6 +1,6 @@ import java.util.Arrays; -public class BubbleSort { +public class 9682142 { public static void main(String args[]) { int [] values = {4, 5 ,6 ,8 ,9 ,10}; bubbleSort(values); -- Gitee From c96f46c0cdf69be476098bd2a8c4ce53663991bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=B0=E8=AF=BA=E6=96=AF?= Date: Tue, 18 Oct 2022 10:23:09 +0000 Subject: [PATCH 3/5] update codes/ywyw22/9682142.java. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杰诺斯 --- codes/ywyw22/9682142.java | 41 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/codes/ywyw22/9682142.java b/codes/ywyw22/9682142.java index 8b96c2c1..2a21f1da 100644 --- a/codes/ywyw22/9682142.java +++ b/codes/ywyw22/9682142.java @@ -1,22 +1,23 @@ -import java.util.Arrays; - -public class 9682142 { - public static void main(String args[]) { - int [] values = {4, 5 ,6 ,8 ,9 ,10}; - bubbleSort(values); - System.out.println(Arrays.toString(values)); +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int j=0;ja[i+1]) + { + temp=a[i]; + a[i]=a[i+1]; + a[i+1]=temp; + } + } } - public static void bubbleSort(int[] values) { - int temp; - for (int i = 0; i < values.length; i++) { - for (int j = 0; j < values.length - 1 - i; j++) { - if (values[j] > values[j + 1]) { - temp = values[j]; - values[j] = values[j + 1]; - values[j + 1] = temp; - } - } - } - } -} +} \ No newline at end of file -- Gitee From 7f15d51cba937ae86d4db8db9b6b5460584b39a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=B0=E8=AF=BA=E6=96=AF?= Date: Tue, 18 Oct 2022 10:26:15 +0000 Subject: [PATCH 4/5] add codes/yinyongchen/9682142.java. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杰诺斯 --- codes/yinyongchen/9682142.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 codes/yinyongchen/9682142.java diff --git a/codes/yinyongchen/9682142.java b/codes/yinyongchen/9682142.java new file mode 100644 index 00000000..2ad3bf89 --- /dev/null +++ b/codes/yinyongchen/9682142.java @@ -0,0 +1,16 @@ +public static void bubbleSort(int [] a, int n){ + for(int j=0;ja[i+1]) + { + temp=a[i]; + a[i]=a[i+1]; + a[i+1]=temp; + } + } + } + +} \ No newline at end of file -- Gitee From 71f0dba89131f0fc3cd796f7c9453e93365618f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=B0=E8=AF=BA=E6=96=AF?= Date: Tue, 18 Oct 2022 10:26:29 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20code?= =?UTF-8?q?s/ywyw22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/ywyw22/9682142.java | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 codes/ywyw22/9682142.java diff --git a/codes/ywyw22/9682142.java b/codes/ywyw22/9682142.java deleted file mode 100644 index 2a21f1da..00000000 --- a/codes/ywyw22/9682142.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 冒泡排序函数 - * aa bb cc - * @param a 待排序的数组 - * @param n 待排序的数组长度 - */ -public static void bubbleSort(int [] a, int n){ - // 你的代码,使无序数组 a 变得有序 - for(int j=0;ja[i+1]) - { - temp=a[i]; - a[i]=a[i+1]; - a[i+1]=temp; - } - } - } - -} \ No newline at end of file -- Gitee