diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..13566b81b018ad684f3a35fee301741b2734c8f4 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml new file mode 100644 index 0000000000000000000000000000000000000000..287a44db1c532d1e5d946c2d09f520df3e241219 --- /dev/null +++ b/.idea/checkstyle-idea.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000000000000000000000000000000000..6560a98983ec708cf9d8b5c5c3776d7bd39c475b --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,36 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..8ed5f34df8494ed90108ce6a2ebd4fa2a8296e95 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..0b11f0fda5d28b0e14ca0fc6150ac9fa519be341 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/15372338.java b/15372338.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/15372338.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/15620229.java b/15620229.java new file mode 100644 index 0000000000000000000000000000000000000000..462bdb84d30a2b7c0d01f9f6822e460a63dd9b1d --- /dev/null +++ b/15620229.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/15651046.java b/15651046.java new file mode 100644 index 0000000000000000000000000000000000000000..fbce6b9fab5d372cc89cb5bb815f4116c001935d --- /dev/null +++ b/15651046.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 0; j < n - i - 1; ++j) { + if(a[j] > a[j + 1]) { + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end + diff --git a/15684741.java b/15684741.java new file mode 100644 index 0000000000000000000000000000000000000000..421e92a6ba7ece3e8dcb629f5fc7bfb9d801c84e --- /dev/null +++ b/15684741.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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]) { + // 交换 arr[j] 和 arr[j + 1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/9619048.java b/9619048.java new file mode 100644 index 0000000000000000000000000000000000000000..49439b988c5b5a64a116feb7bb7eb1809459ccc8 --- /dev/null +++ b/9619048.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过重复地遍历待排序数组,比较并交换相邻元素,使无序数组变得有序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们 + if(a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c8df5b0c4bf4a5c578f5fbbc3c16d85b8216dcb8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2024, njjkxllj +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/activity-school.iml b/activity-school.iml new file mode 100644 index 0000000000000000000000000000000000000000..c76917ee364712f1fe8483123dbecd73d05fea0f --- /dev/null +++ b/activity-school.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/codes/ BHUIJ217892/11003994.java b/codes/ BHUIJ217892/11003994.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/ BHUIJ217892/11003994.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/ Dreamlover/11202583.java b/codes/ Dreamlover/11202583.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/ Dreamlover/11202583.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/ Greeter/11262621.java b/codes/ Greeter/11262621.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/ Greeter/11262621.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ Iboydoss/11210866.java b/codes/ Iboydoss/11210866.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/ Iboydoss/11210866.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ Jingyu/11302198.java b/codes/ Jingyu/11302198.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/ Jingyu/11302198.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ NProgress/11324505.java b/codes/ NProgress/11324505.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/ NProgress/11324505.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/ OPReno/11276365.java b/codes/ OPReno/11276365.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/ OPReno/11276365.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ PHPhph/.keep b/codes/ PHPhph/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/ PHPhph/11120724.java b/codes/ PHPhph/11120724.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/ PHPhph/11120724.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/ Qw2229188799/11089611.java b/codes/ Qw2229188799/11089611.java new file mode 100644 index 0000000000000000000000000000000000000000..607a9246394a817e793043af61e051c104c68f46 --- /dev/null +++ b/codes/ Qw2229188799/11089611.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end diff --git a/codes/ String/11118586.java b/codes/ String/11118586.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/ String/11118586.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ YYDS2023/11094401.java b/codes/ YYDS2023/11094401.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/ YYDS2023/11094401.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/ Z3608759124/10979186.java b/codes/ Z3608759124/10979186.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/ Z3608759124/10979186.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ budasan/11121691.java b/codes/ budasan/11121691.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/ budasan/11121691.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ bupiovm0101/11122657.java b/codes/ bupiovm0101/11122657.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/ bupiovm0101/11122657.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ buzhidao/11118686.java b/codes/ buzhidao/11118686.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/ buzhidao/11118686.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/ deijia909/.keep b/codes/ deijia909/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/ gui8989/11228793.java b/codes/ gui8989/11228793.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/ gui8989/11228793.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ liwei2496/11466656.java b/codes/ liwei2496/11466656.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/ liwei2496/11466656.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/ lovscene/11290992.java b/codes/ lovscene/11290992.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/ lovscene/11290992.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ memuqee/11238999.java b/codes/ memuqee/11238999.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/ memuqee/11238999.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ mupimage/11254168.java b/codes/ mupimage/11254168.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/ mupimage/11254168.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/ neineiya/11260235.java b/codes/ neineiya/11260235.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/ neineiya/11260235.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ openAI12/11234314.java b/codes/ openAI12/11234314.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/ openAI12/11234314.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/ opsation/11293380.java b/codes/ opsation/11293380.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/ opsation/11293380.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ passass/11299378.java b/codes/ passass/11299378.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/ passass/11299378.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/ shelove/.keep b/codes/ shelove/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/ slamer/11242607.java b/codes/ slamer/11242607.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/ slamer/11242607.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ subNvue/11264972.java b/codes/ subNvue/11264972.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/ subNvue/11264972.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/ susuplus/11211308.java b/codes/ susuplus/11211308.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/ susuplus/11211308.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ swgger/11211222.java b/codes/ swgger/11211222.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/ swgger/11211222.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/ ttyylb/11228246.java b/codes/ ttyylb/11228246.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/ ttyylb/11228246.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/ uioplck/11253331.java b/codes/ uioplck/11253331.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/ uioplck/11253331.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ xingwang/11302451.java b/codes/ xingwang/11302451.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/ xingwang/11302451.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ zhoucheng/11464584.java b/codes/ zhoucheng/11464584.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/ zhoucheng/11464584.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ znnzmm/11212509.java b/codes/ znnzmm/11212509.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/ znnzmm/11212509.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/ zouyu5521/11464070.java b/codes/ zouyu5521/11464070.java new file mode 100644 index 0000000000000000000000000000000000000000..a833d8d31b2581029ab106b60f560dd2c73ff238 --- /dev/null +++ b/codes/ zouyu5521/11464070.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + //System.out.println(a); + +} //end \ No newline at end of file diff --git a/codes/.10968772.java.swo b/codes/.10968772.java.swo new file mode 100644 index 0000000000000000000000000000000000000000..2f0782cd2cfb53bcbe2e5e5d2ab0284ecdb06b84 Binary files /dev/null and b/codes/.10968772.java.swo differ diff --git a/codes/.14612723.java.swp b/codes/.14612723.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..ac73c7bef85da8629ba5874ee159d7b3721b6afa Binary files /dev/null and b/codes/.14612723.java.swp differ diff --git a/codes/.15531109.java.swp b/codes/.15531109.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..c864535bd03b34efb00f73d0285538349be06989 Binary files /dev/null and b/codes/.15531109.java.swp differ diff --git a/codes/.9947891.java.swp b/codes/.9947891.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..747e1e75659f3a8001d33ded7f30de27959dd22e Binary files /dev/null and b/codes/.9947891.java.swp differ diff --git a/codes/.9947891.swp b/codes/.9947891.swp new file mode 100644 index 0000000000000000000000000000000000000000..fe92cb7063bbe4dfd1032f38b5a17ecf174b7b7c Binary files /dev/null and b/codes/.9947891.swp differ diff --git a/codes/.9968905.java.swp b/codes/.9968905.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..1ea805f549457592f7d7324cb00d8094cf54a3e5 Binary files /dev/null and b/codes/.9968905.java.swp differ diff --git a/codes/.DS_Store b/codes/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..08398a745c3ed48fadca1439299475676fa814c6 Binary files /dev/null and b/codes/.DS_Store differ diff --git a/codes/10971000.java b/codes/10971000.java new file mode 100644 index 0000000000000000000000000000000000000000..67a97db0f2fbb50ee06aa49da443c533d4552bcd --- /dev/null +++ b/codes/10971000.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { +for (int i=0 ; ia[wll+1]) { +int temp=a[wll]; +a[wll]=a[wll+1]; +a[wll+1]=temp; +} +} +} +} diff --git a/codes/11179070.java b/codes/11179070.java new file mode 100644 index 0000000000000000000000000000000000000000..b6134020eb47b17433f5865ae0f18fa31a59f274 --- /dev/null +++ b/codes/11179070.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end diff --git a/codes/11446072.java b/codes/11446072.java new file mode 100644 index 0000000000000000000000000000000000000000..17fde96e95e5f036bffb1d3aa82fcac932734a29 --- /dev/null +++ b/codes/11446072.java @@ -0,0 +1,19 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 0; j < n-1; j++) { + if(a[j] > a[j+1]){ + int tmp = 0; + tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + } + } + } +} //end diff --git a/codes/15527405.java b/codes/15527405.java new file mode 100644 index 0000000000000000000000000000000000000000..cb54d2b32482419f700300ea22b13488343a544b --- /dev/null +++ b/codes/15527405.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } +} //end diff --git a/codes/15541001.java b/codes/15541001.java new file mode 100644 index 0000000000000000000000000000000000000000..324687283489419c5a6916c234a8848f65a5eb64 --- /dev/null +++ b/codes/15541001.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int tata = 0; tata < n - i - 1; tata++) { + if(a[tata] > a[tata + 1]) { + int temp = a[tata]; + a [tata] = a[tata + 1]; + a[tata + 1] = temp; + } + } + } + + +} //end,tatazj diff --git a/codes/15582699.java b/codes/15582699.java new file mode 100644 index 0000000000000000000000000000000000000000..e8b6c17bfddeca239363a2e17b4e7c55c1cbbcfc --- /dev/null +++ b/codes/15582699.java @@ -0,0 +1,18 @@ +OB/** + * 冒泡排序函数 + * 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]) { + // 交换a[j]和a[j+1]的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/15585762.java b/codes/15585762.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/15585762.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/15607358.java b/codes/15607358.java new file mode 100644 index 0000000000000000000000000000000000000000..ebbb1f9f8af1b6c610ac86c2a1d260b37da2d0b7 --- /dev/null +++ b/codes/15607358.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换相邻两个元素的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} + diff --git a/codes/15620229.java b/codes/15620229.java new file mode 100644 index 0000000000000000000000000000000000000000..462bdb84d30a2b7c0d01f9f6822e460a63dd9b1d --- /dev/null +++ b/codes/15620229.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/15636076.java b/codes/15636076.java new file mode 100644 index 0000000000000000000000000000000000000000..65e242d018acedd1acc99659aaa896db112c5c58 --- /dev/null +++ b/codes/15636076.java @@ -0,0 +1,19 @@ +```java +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end diff --git a/codes/15699820.java b/codes/15699820.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/15699820.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/15700256.java b/codes/15700256.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/15700256.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/15700309.java b/codes/15700309.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/15700309.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/15732362.java b/codes/15732362.java new file mode 100644 index 0000000000000000000000000000000000000000..080b9658f9727c7d90618127cb6d7f9b5162b1d9 --- /dev/null +++ b/codes/15732362.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // endi diff --git a/codes/15759151.java b/codes/15759151.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/15759151.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/9622480.java b/codes/9622480.java new file mode 100644 index 0000000000000000000000000000000000000000..02b68330dadebd99139bc7a1bcc7757cb621cbca --- /dev/null +++ b/codes/9622480.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过重复地遍历待排序数组,比较并交换相邻元素,使无序数组变得有序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们 + if(a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/9785926.java b/codes/9785926.java new file mode 100644 index 0000000000000000000000000000000000000000..10dbc6525b8c4427dda5055b3f3c224c68398d2c --- /dev/null +++ b/codes/9785926.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end diff --git a/codes/A1607142431/10995009.java b/codes/A1607142431/10995009.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/A1607142431/10995009.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/A17355931314/15646257.java b/codes/A17355931314/15646257.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/A17355931314/15646257.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/A17730000544/15630407.java b/codes/A17730000544/15630407.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/A17730000544/15630407.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/A17864115054/15528622.java b/codes/A17864115054/15528622.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/A17864115054/15528622.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/A19356583352/15628459.java b/codes/A19356583352/15628459.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/A19356583352/15628459.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/A7777777/11213040.java b/codes/A7777777/11213040.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/A7777777/11213040.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/A853047901/.java b/codes/A853047901/.java new file mode 100644 index 0000000000000000000000000000000000000000..0d5a14b00410819d7cb653a0daa1a319eb87c03c --- /dev/null +++ b/codes/A853047901/.java @@ -0,0 +1,64 @@ +ad + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/codes/A853047901/10845109.java b/codes/A853047901/10845109.java new file mode 100644 index 0000000000000000000000000000000000000000..ab3d8f390cfa4cee1947d39872e75bac48b3058a --- /dev/null +++ b/codes/A853047901/10845109.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/A8888888/11187517.java b/codes/A8888888/11187517.java new file mode 100644 index 0000000000000000000000000000000000000000..9c9fea7e5a6f112ef881921d767eabc005fa9092 --- /dev/null +++ b/codes/A8888888/11187517.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end diff --git a/codes/AA15930757026/15765678.java b/codes/AA15930757026/15765678.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/AA15930757026/15765678.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/ABOD01/11326499.java b/codes/ABOD01/11326499.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/ABOD01/11326499.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/ARSHAM/11202647.java b/codes/ARSHAM/11202647.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/ARSHAM/11202647.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/ASD8899/.keep b/codes/ASD8899/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/ASD8899/15742420.java b/codes/ASD8899/15742420.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/ASD8899/15742420.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ASR1523580/15669420.java b/codes/ASR1523580/15669420.java new file mode 100644 index 0000000000000000000000000000000000000000..02a20ce54b5eb4c0667f7a563b4df0adc5785297 --- /dev/null +++ b/codes/ASR1523580/15669420.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较和交换,将较大的元素逐步“浮”到数组的末尾,实现排序 + * @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 - 1 - i; j++) { // 内层循环控制每轮比较的次数 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/Aa12345678/.keep b/codes/Aa12345678/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Aa12345678/10043731.java b/codes/Aa12345678/10043731.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/Aa12345678/10043731.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/Airbnb/11260348.java b/codes/Airbnb/11260348.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/Airbnb/11260348.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Amyaaa/15624605.java b/codes/Amyaaa/15624605.java new file mode 100644 index 0000000000000000000000000000000000000000..ad8ad09a2f9c88791a9e320badbe7431bfe97c08 --- /dev/null +++ b/codes/Amyaaa/15624605.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过相邻元素之间的比较和交换,使得每一轮比较后最大(或最小)的元素能够"冒泡"到数组的末尾。 + * @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]) { // 如果前一个元素比后一个元素大,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/Anheqiao/15630084.java b/codes/Anheqiao/15630084.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Anheqiao/15630084.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Anheqiao0512/15535529.java b/codes/Anheqiao0512/15535529.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/Anheqiao0512/15535529.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/AnolisOpen/9754131.java b/codes/AnolisOpen/9754131.java new file mode 100644 index 0000000000000000000000000000000000000000..90103364fd2d7804bcb50390b65e743a21bba374 --- /dev/null +++ b/codes/AnolisOpen/9754131.java @@ -0,0 +1,20 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end + + diff --git a/codes/AuuuAa/11292635.java b/codes/AuuuAa/11292635.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/AuuuAa/11292635.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Ayuanlou/15592112.java b/codes/Ayuanlou/15592112.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/Ayuanlou/15592112.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/BHUIJ217892/11003994.java b/codes/BHUIJ217892/11003994.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/BHUIJ217892/11003994.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Beca0101/11118448.java b/codes/Beca0101/11118448.java new file mode 100644 index 0000000000000000000000000000000000000000..029e9d84c1474520908887693e69aabcb7ff0aba --- /dev/null +++ b/codes/Beca0101/11118448.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 +*/ +public static void bubbleSort(int [] a, int n){ + int j , k; + int flag = n ;//flag来记录最后交换的位置,也就是排序的尾边界 + + while (flag > 0){//排序未结束标志 + k = flag; //k 来记录遍历的尾边界 + flag = 0; + + for(j=1; j a[j]){//前面的数字大于后面的数字就交换 + //交换a[j-1]和a[j] + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j]=temp; + + //表示交换过数据; + flag = j;//记录最新的尾边界. + } + } + } +} \ No newline at end of file diff --git a/codes/BrokenDreams/11287383.java b/codes/BrokenDreams/11287383.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/BrokenDreams/11287383.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/CC422AAACC/.keep b/codes/CC422AAACC/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/CC422AAACC/15742406.java b/codes/CC422AAACC/15742406.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/CC422AAACC/15742406.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/CKXGZXA/14237106.java b/codes/CKXGZXA/14237106.java new file mode 100644 index 0000000000000000000000000000000000000000..60c32309776bdae63a5929fa9f76b4d197f9bfdd --- /dev/null +++ b/codes/CKXGZXA/14237106.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + // 如果相邻元素逆序,则交换它们 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + + +} //end diff --git a/codes/CS_Joer/11449450.java b/codes/CS_Joer/11449450.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/CS_Joer/11449450.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/Calli990/11027717.java b/codes/Calli990/11027717.java new file mode 100644 index 0000000000000000000000000000000000000000..a833d8d31b2581029ab106b60f560dd2c73ff238 --- /dev/null +++ b/codes/Calli990/11027717.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + //System.out.println(a); + +} //end \ No newline at end of file diff --git a/codes/CangBOP/11303209.java b/codes/CangBOP/11303209.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/CangBOP/11303209.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Cannon/11268645.java b/codes/Cannon/11268645.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/Cannon/11268645.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Case19523171659/.keep b/codes/Case19523171659/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Case19523171659/10972507.java b/codes/Case19523171659/10972507.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/Case19523171659/10972507.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/Charles953/11342263.java b/codes/Charles953/11342263.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/Charles953/11342263.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/Chat-4/11187682.java b/codes/Chat-4/11187682.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/Chat-4/11187682.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/CheeseMen/11466037.java b/codes/CheeseMen/11466037.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/CheeseMen/11466037.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/ChengRunji/15532439.java b/codes/ChengRunji/15532439.java new file mode 100644 index 0000000000000000000000000000000000000000..2252b818e6125ed4f8bbd23eca03c12c15ca1757 --- /dev/null +++ b/codes/ChengRunji/15532439.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/Chengxiaoyu/15650592.java b/codes/Chengxiaoyu/15650592.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Chengxiaoyu/15650592.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Christopher/15635786.java b/codes/Christopher/15635786.java new file mode 100644 index 0000000000000000000000000000000000000000..9c9fea7e5a6f112ef881921d767eabc005fa9092 --- /dev/null +++ b/codes/Christopher/15635786.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end diff --git a/codes/Chuck395/11358350.java b/codes/Chuck395/11358350.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/Chuck395/11358350.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/Colazxk/9952351.java b/codes/Colazxk/9952351.java new file mode 100644 index 0000000000000000000000000000000000000000..53759c2f48f52ac41393572a21510648027f32cd --- /dev/null +++ b/codes/Colazxk/9952351.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + int t=a[j]; + a[j]=a[j+1]; + a[j+1]=t; + } + } + } + +} //end diff --git a/codes/CuiChenyuan/15758456.java b/codes/CuiChenyuan/15758456.java new file mode 100644 index 0000000000000000000000000000000000000000..2252b818e6125ed4f8bbd23eca03c12c15ca1757 --- /dev/null +++ b/codes/CuiChenyuan/15758456.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/D15059170203/.keep b/codes/D15059170203/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/D15059170203/10976249.java b/codes/D15059170203/10976249.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/D15059170203/10976249.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/DENGXC/10553088.java b/codes/DENGXC/10553088.java new file mode 100644 index 0000000000000000000000000000000000000000..7db1ed71c900652c30e8b1c3e9172e685287856a --- /dev/null +++ b/codes/DENGXC/10553088.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int []arr, int n) { + 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+1]; + arr[j+1] = arr[j]; + arr[j] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/DH13480641255/15621028.java b/codes/DH13480641255/15621028.java new file mode 100644 index 0000000000000000000000000000000000000000..38ba933c754afe70ecd4b39c7b225fe0231cfc11 --- /dev/null +++ b/codes/DH13480641255/15621028.java @@ -0,0 +1,20 @@ + +/** + * 冒泡排序函数 + * 实现数组的冒泡排序 + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] 的值 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/DaybyDay/11117022.java b/codes/DaybyDay/11117022.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/DaybyDay/11117022.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/DeepThinking/11452012.java b/codes/DeepThinking/11452012.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/DeepThinking/11452012.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/Dgwoisdg/11001326.java b/codes/Dgwoisdg/11001326.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/Dgwoisdg/11001326.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/Dreamlover/11202583.java b/codes/Dreamlover/11202583.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/Dreamlover/11202583.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/Duvet123/11306690.java b/codes/Duvet123/11306690.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/Duvet123/11306690.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/EthanLeo/10155282.java b/codes/EthanLeo/10155282.java new file mode 100644 index 0000000000000000000000000000000000000000..f920043964316c8b98cc5590b2416759315d88b8 --- /dev/null +++ b/codes/EthanLeo/10155282.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end diff --git a/codes/Evening/15453362.java b/codes/Evening/15453362.java new file mode 100644 index 0000000000000000000000000000000000000000..74d00cd537347abc649db59a9c02dc1f89ee0c8b --- /dev/null +++ b/codes/Evening/15453362.java @@ -0,0 +1,25 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + boolean flag = false; + + 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; + flag = true; + } + } + + if (!flag) { + break; + } + } +} //end diff --git a/codes/FOYEGE/11326121.java b/codes/FOYEGE/11326121.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/FOYEGE/11326121.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/Faweiya/11259965.java b/codes/Faweiya/11259965.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/Faweiya/11259965.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/FbxgIt/11302915.java b/codes/FbxgIt/11302915.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/FbxgIt/11302915.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Fickler/15510871.java b/codes/Fickler/15510871.java new file mode 100644 index 0000000000000000000000000000000000000000..09064e0de2a17f59f9d03567fa6cd8733beb1238 --- /dev/null +++ b/codes/Fickler/15510871.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较和交换,将最大(或最小)的元素冒泡到数组末尾。 + * 重复执行,直到整个数组有序。 + * @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 - 1 - i; j++) { // 内层循环控制每一趟排序多少次 + if (a[j] > a[j + 1]) { // 相邻元素两两比较,如果前一个元素比后一个元素大则交换它们 + // 交换 a[j] 和 a[j + 1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end bubbleSort diff --git a/codes/Fitz_dev/9948244.java b/codes/Fitz_dev/9948244.java new file mode 100644 index 0000000000000000000000000000000000000000..191de91d18bdb330ab1609aaa3b20eeb19226481 --- /dev/null +++ b/codes/Fitz_dev/9948244.java @@ -0,0 +1,11 @@ + public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < a.length - 1; i++) { + for (int j = 0; j < a.length - 1 - i; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j + 1]; + a[j + 1] = a[j]; + a[j] = temp; + } + } + } + } \ No newline at end of file diff --git a/codes/Fog16623132936/.keep b/codes/Fog16623132936/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Fog16623132936/10972627.java b/codes/Fog16623132936/10972627.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/Fog16623132936/10972627.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/Fuysus/15342593.java b/codes/Fuysus/15342593.java new file mode 100644 index 0000000000000000000000000000000000000000..42efb78bd2fda83f4dd10b8e410a507cadd6f995 --- /dev/null +++ b/codes/Fuysus/15342593.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 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]) + { + a[j] = a[j] ^ a[j+1]; + a[j+1] = a[j] ^ a[j+1]; + a[j] = a[j]^ a[j+1]; + } + } + } +} diff --git a/codes/GUIDM1966/15524857.java b/codes/GUIDM1966/15524857.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/GUIDM1966/15524857.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Gesture/11255850.java b/codes/Gesture/11255850.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/Gesture/11255850.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Ghib66/15510318.java b/codes/Ghib66/15510318.java new file mode 100644 index 0000000000000000000000000000000000000000..a347a636e0d7dd3b4246030898b4eb7a389aedb6 --- /dev/null +++ b/codes/Ghib66/15510318.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end diff --git a/codes/GoStraightOn/14341961.java b/codes/GoStraightOn/14341961.java new file mode 100644 index 0000000000000000000000000000000000000000..6115f0ce1ea819bc98cdd13856a7b2619b01db61 --- /dev/null +++ b/codes/GoStraightOn/14341961.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; ++j){ + if(a[j] > a[j+1]){ + int k = a[j]; + a[j] = a[j+1]; + a[j+1] = k; + } + } + } +} //end diff --git a/codes/Greeter/11262621.java b/codes/Greeter/11262621.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/Greeter/11262621.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Guna777/15714682.java b/codes/Guna777/15714682.java new file mode 100644 index 0000000000000000000000000000000000000000..7ba11c491b7e3e78e934dce29820c01e071d926a --- /dev/null +++ b/codes/Guna777/15714682.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较和交换,将较大的元素逐渐“浮”到数组的末尾,从而完成排序 + * @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 - 1 - i; j++) { + // 如果前一个元素比后一个元素大,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + // 当外层循环和内层循环都执行完毕后,数组a已变为有序 +} //end diff --git a/codes/HMqusi/11299684.java b/codes/HMqusi/11299684.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/HMqusi/11299684.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/HUmui0101/11027238.java b/codes/HUmui0101/11027238.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/HUmui0101/11027238.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/HandsomeSean/11463861.java b/codes/HandsomeSean/11463861.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/HandsomeSean/11463861.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/HeRuo123/15520250.java b/codes/HeRuo123/15520250.java new file mode 100644 index 0000000000000000000000000000000000000000..1f0c75d37de508002cfe9323af47f87cc3264e88 --- /dev/null +++ b/codes/HeRuo123/15520250.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} + diff --git a/codes/HelloWorld1/11257582.java b/codes/HelloWorld1/11257582.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/HelloWorld1/11257582.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/Henriette/11038762.java b/codes/Henriette/11038762.java new file mode 100644 index 0000000000000000000000000000000000000000..efb824a489dc8b727f3bfc156b5793c17767c02d --- /dev/null +++ b/codes/Henriette/11038762.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0;ia[j+1]) { + tmp = a[j+1]; + a[j+1] = a[j]; + a[j] = tmp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/Hksr223/15534956.java b/codes/Hksr223/15534956.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Hksr223/15534956.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/HotSpringEye/11446072.java b/codes/HotSpringEye/11446072.java new file mode 100644 index 0000000000000000000000000000000000000000..17fde96e95e5f036bffb1d3aa82fcac932734a29 --- /dev/null +++ b/codes/HotSpringEye/11446072.java @@ -0,0 +1,19 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 0; j < n-1; j++) { + if(a[j] > a[j+1]){ + int tmp = 0; + tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + } + } + } +} //end diff --git a/codes/HunterHans/12287484.java b/codes/HunterHans/12287484.java new file mode 100644 index 0000000000000000000000000000000000000000..ab3d8f390cfa4cee1947d39872e75bac48b3058a --- /dev/null +++ b/codes/HunterHans/12287484.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/IM12138/11469383.java b/codes/IM12138/11469383.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/IM12138/11469383.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/IXHE2004/15639769.java b/codes/IXHE2004/15639769.java new file mode 100644 index 0000000000000000000000000000000000000000..92fad2772ec71c37138adb4f351dd2ff2abf77f7 --- /dev/null +++ b/codes/IXHE2004/15639769.java @@ -0,0 +1,25 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n - 1; i++){ + boolean swapped = false; + 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; + swapped = true; + } + } + if(!swapped){ + break; + } + } + + +} //end diff --git a/codes/Iboydoss/11210866.java b/codes/Iboydoss/11210866.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/Iboydoss/11210866.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/IoTanw/11135258.java b/codes/IoTanw/11135258.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/IoTanw/11135258.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/JJ18809227089/15752040.java b/codes/JJ18809227089/15752040.java new file mode 100644 index 0000000000000000000000000000000000000000..818e91524d6786d8c2e0dac24368b79d3395558c --- /dev/null +++ b/codes/JJ18809227089/15752040.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 实现冒泡排序算法对数组进行升序排序 + * @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 diff --git a/codes/JackieYe/15543330.java b/codes/JackieYe/15543330.java new file mode 100644 index 0000000000000000000000000000000000000000..4cb5df82ea987d9fa35001f4e783a0dc005030df --- /dev/null +++ b/codes/JackieYe/15543330.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 对数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/Jang10/15536247.java b/codes/Jang10/15536247.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Jang10/15536247.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/January/.keep b/codes/January/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/January/11070767.java b/codes/January/11070767.java new file mode 100644 index 0000000000000000000000000000000000000000..2bc93cadc50baaddb1c4cb8426d848cafbe04c0d --- /dev/null +++ b/codes/January/11070767.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 = i+1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[i]; + a[i] = a[j]; + a[j] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/JasenChao/13984025.java b/codes/JasenChao/13984025.java new file mode 100644 index 0000000000000000000000000000000000000000..8b3ae08584db3b5f717703183280ee686b85e555 --- /dev/null +++ b/codes/JasenChao/13984025.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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + int t = a[j]; + a[j] = a[j + 1]; + a[j + 1] = t; + } + } + } +} //end diff --git a/codes/Jasonakeke/15520912.java b/codes/Jasonakeke/15520912.java new file mode 100644 index 0000000000000000000000000000000000000000..9167756b83f8756b4e75585ce4edbb8589e589bb --- /dev/null +++ b/codes/Jasonakeke/15520912.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过相邻元素比较和交换,使得每一轮迭代后最大(或最小)的元素被移动到数组的末尾。 + * @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 diff --git a/codes/Jgf3096619665/15774713.java b/codes/Jgf3096619665/15774713.java new file mode 100644 index 0000000000000000000000000000000000000000..1cabf6d136484b1313d87727d7689c90ecbfaff3 --- /dev/null +++ b/codes/Jgf3096619665/15774713.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较和交换,使得每一轮循环后最大(或最小)的元素能够“冒泡”到数组的末尾 + * @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 - 1 - i; j++) { // 内层循环控制每趟排序的过程 + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/Jingyu/11302198.java b/codes/Jingyu/11302198.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/Jingyu/11302198.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/Juliani/11207255.java b/codes/Juliani/11207255.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/Juliani/11207255.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/K18475329871/15592083.java b/codes/K18475329871/15592083.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/K18475329871/15592083.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Kang12138/15653043.java b/codes/Kang12138/15653043.java new file mode 100644 index 0000000000000000000000000000000000000000..45f0745ac6230b9ee65fd1fc81955aaafb291621 --- /dev/null +++ b/codes/Kang12138/15653043.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * 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 - 1 - i; j++) { + // 如果当前数比下一个数大,交换它们 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + + diff --git a/codes/KijD_wyp/15647839.java b/codes/KijD_wyp/15647839.java new file mode 100644 index 0000000000000000000000000000000000000000..5403354dc82f171186f125d43576ddd280c9a37a --- /dev/null +++ b/codes/KijD_wyp/15647839.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 功能:对数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/Kio1262902996/11044068.java b/codes/Kio1262902996/11044068.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/Kio1262902996/11044068.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Kristen/11804698.java b/codes/Kristen/11804698.java new file mode 100644 index 0000000000000000000000000000000000000000..fcd1392a4e24c037551bc75309c7d023ecd2e22f --- /dev/null +++ b/codes/Kristen/11804698.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/LS2698853114/15540958.java b/codes/LS2698853114/15540958.java new file mode 100644 index 0000000000000000000000000000000000000000..a7e15843a04a39100dcec79c259a955307b2a501 --- /dev/null +++ b/codes/LS2698853114/15540958.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * 功能:对输入的整数数组进行冒泡排序 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 标志位,表示这一趟是否有交换 + boolean swapped = false; + 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; + // 发生了交换,将标志位设为true + swapped = true; + } + } + // 如果在内层循环中没有发生交换,说明数组已经有序,可以退出排序 + if (!swapped) { + break; + } + } +} // end diff --git a/codes/LatiaoPro/11352722.java b/codes/LatiaoPro/11352722.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/LatiaoPro/11352722.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/LightLeaf/14443538.java b/codes/LightLeaf/14443538.java new file mode 100644 index 0000000000000000000000000000000000000000..926b81024fd86b5e4f59fe93b0b5e8e8e9536b3d --- /dev/null +++ b/codes/LightLeaf/14443538.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + int i=0; + int temp; + while(ia[j+1]){ + temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + i++; + } +} //end diff --git a/codes/Likui123/.keep b/codes/Likui123/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Likui123/15713905.java b/codes/Likui123/15713905.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/Likui123/15713905.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/Lishen/.keep b/codes/Lishen/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Lishen/15630879.java b/codes/Lishen/15630879.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/Lishen/15630879.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/Lorin210926/15605953.java b/codes/Lorin210926/15605953.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/Lorin210926/15605953.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/Lundyli/11471416.java b/codes/Lundyli/11471416.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/Lundyli/11471416.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Lyw413181892/15630146.java b/codes/Lyw413181892/15630146.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b711a46fe664a20752955f5730ee67702ccb8b --- /dev/null +++ b/codes/Lyw413181892/15630146.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int huat = 0; huat < n - i - 1; huat++) { + if(a[huat] > a[huat + 1]) { + int temp = a[huat]; + a [huat] = a[huat + 1]; + a[huat + 1] = temp; + } + } + } + + +} //end,huat diff --git a/codes/M8M9900/11211820.java b/codes/M8M9900/11211820.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/M8M9900/11211820.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/MIngDx/11303026.java b/codes/MIngDx/11303026.java new file mode 100644 index 0000000000000000000000000000000000000000..029e9d84c1474520908887693e69aabcb7ff0aba --- /dev/null +++ b/codes/MIngDx/11303026.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 +*/ +public static void bubbleSort(int [] a, int n){ + int j , k; + int flag = n ;//flag来记录最后交换的位置,也就是排序的尾边界 + + while (flag > 0){//排序未结束标志 + k = flag; //k 来记录遍历的尾边界 + flag = 0; + + for(j=1; j a[j]){//前面的数字大于后面的数字就交换 + //交换a[j-1]和a[j] + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j]=temp; + + //表示交换过数据; + flag = j;//记录最新的尾边界. + } + } + } +} \ No newline at end of file diff --git a/codes/Martin-9527/15628832.java b/codes/Martin-9527/15628832.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/Martin-9527/15628832.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/MaxLeton/.15571733.java.swp b/codes/MaxLeton/.15571733.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..48a16a164a447d809c471f303c8ca39d8de57ac9 Binary files /dev/null and b/codes/MaxLeton/.15571733.java.swp differ diff --git a/codes/MaxLeton/15562550.java b/codes/MaxLeton/15562550.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15562550.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 diff --git a/codes/MaxLeton/15571733.java b/codes/MaxLeton/15571733.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15571733.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 diff --git a/codes/MaxLeton/15575568.java b/codes/MaxLeton/15575568.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15575568.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 diff --git a/codes/MaxLeton/15576146.java b/codes/MaxLeton/15576146.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15576146.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 diff --git a/codes/MaxLeton/15576148.java b/codes/MaxLeton/15576148.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15576148.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 diff --git a/codes/MaxLeton/15576152.java b/codes/MaxLeton/15576152.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15576152.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 diff --git a/codes/MaxLeton/15579562.java b/codes/MaxLeton/15579562.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15579562.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 diff --git a/codes/MaxLeton/15579566.java b/codes/MaxLeton/15579566.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15579566.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 diff --git a/codes/MaxLeton/15579567.java b/codes/MaxLeton/15579567.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15579567.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 diff --git a/codes/MaxLeton/15579569.java b/codes/MaxLeton/15579569.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15579569.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 diff --git a/codes/MaxLeton/15579570.java b/codes/MaxLeton/15579570.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15579570.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 diff --git a/codes/MaxLeton/15594053.java b/codes/MaxLeton/15594053.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15594053.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 diff --git a/codes/MaxLeton/15594054.java b/codes/MaxLeton/15594054.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15594054.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 diff --git a/codes/MaxLeton/15594056.java b/codes/MaxLeton/15594056.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15594056.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 diff --git a/codes/MaxLeton/15594059.java b/codes/MaxLeton/15594059.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15594059.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 diff --git a/codes/MaxLeton/15594060.java b/codes/MaxLeton/15594060.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15594060.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 diff --git a/codes/MaxLeton/15608880.java b/codes/MaxLeton/15608880.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15608880.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 diff --git a/codes/MaxLeton/15608883.java b/codes/MaxLeton/15608883.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15608883.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 diff --git a/codes/MaxLeton/15608887.java b/codes/MaxLeton/15608887.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15608887.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 diff --git a/codes/MaxLeton/15608889.java b/codes/MaxLeton/15608889.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15608889.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 diff --git a/codes/MaxLeton/15608891.java b/codes/MaxLeton/15608891.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15608891.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 diff --git a/codes/MaxLeton/15626095.java b/codes/MaxLeton/15626095.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15626095.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 diff --git a/codes/MaxLeton/15626097.java b/codes/MaxLeton/15626097.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15626097.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 diff --git a/codes/MaxLeton/15626100.java b/codes/MaxLeton/15626100.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15626100.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 diff --git a/codes/MaxLeton/15626101.java b/codes/MaxLeton/15626101.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15626101.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 diff --git a/codes/MaxLeton/15626102.java b/codes/MaxLeton/15626102.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15626102.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 diff --git a/codes/MaxLeton/15655523.java b/codes/MaxLeton/15655523.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15655523.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 diff --git a/codes/MaxLeton/15655527.java b/codes/MaxLeton/15655527.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15655527.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 diff --git a/codes/MaxLeton/15655529.java b/codes/MaxLeton/15655529.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15655529.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 diff --git a/codes/MaxLeton/15655530.java b/codes/MaxLeton/15655530.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15655530.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 diff --git a/codes/MaxLeton/15655532.java b/codes/MaxLeton/15655532.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15655532.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 diff --git a/codes/MaxLeton/15670770.java b/codes/MaxLeton/15670770.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15670770.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 diff --git a/codes/MaxLeton/15670771.java b/codes/MaxLeton/15670771.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15670771.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 diff --git a/codes/MaxLeton/15670774.java b/codes/MaxLeton/15670774.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15670774.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 diff --git a/codes/MaxLeton/15670778.java b/codes/MaxLeton/15670778.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15670778.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 diff --git a/codes/MaxLeton/15670781.java b/codes/MaxLeton/15670781.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15670781.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 diff --git a/codes/MaxLeton/15689390.java b/codes/MaxLeton/15689390.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15689390.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 diff --git a/codes/MaxLeton/15689391.java b/codes/MaxLeton/15689391.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15689391.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 diff --git a/codes/MaxLeton/15689394.java b/codes/MaxLeton/15689394.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15689394.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 diff --git a/codes/MaxLeton/15689395.java b/codes/MaxLeton/15689395.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15689395.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 diff --git a/codes/MaxLeton/15689399.java b/codes/MaxLeton/15689399.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15689399.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 diff --git a/codes/MaxLeton/15701706.java b/codes/MaxLeton/15701706.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15701706.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 diff --git a/codes/MaxLeton/15701711.java b/codes/MaxLeton/15701711.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15701711.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 diff --git a/codes/MaxLeton/15701714.java b/codes/MaxLeton/15701714.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15701714.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 diff --git a/codes/MaxLeton/15701718.java b/codes/MaxLeton/15701718.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15701718.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 diff --git a/codes/MaxLeton/15701720.java b/codes/MaxLeton/15701720.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15701720.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 diff --git a/codes/MaxLeton/15716047.java b/codes/MaxLeton/15716047.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15716047.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 diff --git a/codes/MaxLeton/15716048.java b/codes/MaxLeton/15716048.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15716048.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 diff --git a/codes/MaxLeton/15716049.java b/codes/MaxLeton/15716049.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15716049.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 diff --git a/codes/MaxLeton/15716050.java b/codes/MaxLeton/15716050.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15716050.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 diff --git a/codes/MaxLeton/15716053.java b/codes/MaxLeton/15716053.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15716053.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 diff --git a/codes/MaxLeton/15747350.java b/codes/MaxLeton/15747350.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15747350.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 diff --git a/codes/MaxLeton/15747354.java b/codes/MaxLeton/15747354.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15747354.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 diff --git a/codes/MaxLeton/15747356.java b/codes/MaxLeton/15747356.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15747356.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 diff --git a/codes/MaxLeton/15747359.java b/codes/MaxLeton/15747359.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15747359.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 diff --git a/codes/MaxLeton/15747361.java b/codes/MaxLeton/15747361.java new file mode 100644 index 0000000000000000000000000000000000000000..4fe168de370c66365f5713fe8aa4aad2854eb4c7 --- /dev/null +++ b/codes/MaxLeton/15747361.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 diff --git a/codes/Meng527/10036105.java b/codes/Meng527/10036105.java new file mode 100644 index 0000000000000000000000000000000000000000..42e67aad9e029c8f4c3b18060f793ece1a13fd52 --- /dev/null +++ b/codes/Meng527/10036105.java @@ -0,0 +1,19 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end + diff --git a/codes/Monorepo/11203800.java b/codes/Monorepo/11203800.java new file mode 100644 index 0000000000000000000000000000000000000000..326c3a0554691a64116fdb35f3b09a4a64bac4a6 --- /dev/null +++ b/codes/Monorepo/11203800.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 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 swap = 0; + swap = a[j]; + a[j] = a[j+1]; + a[j+1] = swap; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Mrzhao/11115789.java b/codes/Mrzhao/11115789.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/Mrzhao/11115789.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/MuZiNan/.15657839.java.swp b/codes/MuZiNan/.15657839.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..09374482e60ca124f6bc6c7d84df8b257de59da0 Binary files /dev/null and b/codes/MuZiNan/.15657839.java.swp differ diff --git a/codes/MuZiNan/10041393.java b/codes/MuZiNan/10041393.java new file mode 100644 index 0000000000000000000000000000000000000000..7259ea268cf9a8941f87f19ca379946024c29c4c --- /dev/null +++ b/codes/MuZiNan/10041393.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} + diff --git a/codes/MuZiNan/15657839.java b/codes/MuZiNan/15657839.java new file mode 100644 index 0000000000000000000000000000000000000000..51d71b839734af55652e8a90493143d1142e9f7b --- /dev/null +++ b/codes/MuZiNan/15657839.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} diff --git a/codes/Muzizy/15639710.java b/codes/Muzizy/15639710.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Muzizy/15639710.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Myron520/15614791.java b/codes/Myron520/15614791.java new file mode 100644 index 0000000000000000000000000000000000000000..e5ce3441552dd06706ba79382d6f2f719655d2d5 --- /dev/null +++ b/codes/Myron520/15614791.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for (i = n - 1; i > 0; i--) { + // 将a[0...i]中最大的数据放在末尾 + for (j = 0; j < i; j++) { + + if (a[j] > a[j + 1]) { + // 交换a[j]和a[j+1] + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end diff --git a/codes/NANF41/11116589.java b/codes/NANF41/11116589.java new file mode 100644 index 0000000000000000000000000000000000000000..2289d8d3c812b3aecf7020370a798acfdcad1bcb --- /dev/null +++ b/codes/NANF41/11116589.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/NProgress/11324505.java b/codes/NProgress/11324505.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/NProgress/11324505.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/NX9990/15752874.java b/codes/NX9990/15752874.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/NX9990/15752874.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Navigation1/11130536.java b/codes/Navigation1/11130536.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/Navigation1/11130536.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Ni123456/15562619.java b/codes/Ni123456/15562619.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Ni123456/15562619.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Ni123456/15630872.java b/codes/Ni123456/15630872.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Ni123456/15630872.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/OPReno/11276365.java b/codes/OPReno/11276365.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/OPReno/11276365.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/OceanBase/11302025.java b/codes/OceanBase/11302025.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/OceanBase/11302025.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/OnMoreTime/10860781.java b/codes/OnMoreTime/10860781.java new file mode 100644 index 0000000000000000000000000000000000000000..c05a772d83b85c60bdcae220bf3d2ed176d8e54c --- /dev/null +++ b/codes/OnMoreTime/10860781.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp; + for (int i = 0; i < n - 1; i++) { + int count = 0; + for (int j = 0; j < n - 1 - i; j++) { + if (a[j] > a[j + 1]) { + temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + count++; + } + } + if (count == 0) { + break; + } + } +} //end diff --git a/codes/OneMuMu/11370801.java b/codes/OneMuMu/11370801.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/OneMuMu/11370801.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/OutlEts/11343931.java b/codes/OutlEts/11343931.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/OutlEts/11343931.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/P4rt01/15689858.java b/codes/P4rt01/15689858.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/P4rt01/15689858.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/PHPhph/11120724.java b/codes/PHPhph/11120724.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/PHPhph/11120724.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/PUAdewo/11303488.java b/codes/PUAdewo/11303488.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/PUAdewo/11303488.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/PexoPexo/11116939.java b/codes/PexoPexo/11116939.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/PexoPexo/11116939.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/Platform/11203867.java b/codes/Platform/11203867.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/Platform/11203867.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Q2529807676/15563540.java b/codes/Q2529807676/15563540.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/Q2529807676/15563540.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/Q8888688888/11213062.java b/codes/Q8888688888/11213062.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/Q8888688888/11213062.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/QiQi77/15719621.java b/codes/QiQi77/15719621.java new file mode 100644 index 0000000000000000000000000000000000000000..5b72062d2b1ddce9651234f7c8f7a161c1fda294 --- /dev/null +++ b/codes/QiQi77/15719621.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * 通过相邻元素之间的比较和交换,将最大的元素“冒泡”到数组的末尾 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 标记是否有交换发生,用于优化,如果这一趟没有交换,说明已经有序 + boolean swapped = false; + 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; + // 标记发生了交换 + swapped = true; + } + } + // 如果没有发生交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/Qking123/.15572198.java.swp b/codes/Qking123/.15572198.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..17a500efb8338413057a3263ea6b3bd86e91a689 Binary files /dev/null and b/codes/Qking123/.15572198.java.swp differ diff --git a/codes/Qking123/15572198.java b/codes/Qking123/15572198.java new file mode 100644 index 0000000000000000000000000000000000000000..13964cf88a3816898961bf686295ad15ef199de5 --- /dev/null +++ b/codes/Qking123/15572198.java @@ -0,0 +1,39 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +/*pulick static void bubbleSort(int []a, int n) { + boolean flag = false; + for (int i = 0; i < n; 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; + } + } + if (flag == false){ + break; + }else { + flag = false; + } + } +} //end +*/ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end diff --git a/codes/Qw2229188799/11089611.java b/codes/Qw2229188799/11089611.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/Qw2229188799/11089611.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/Qw25526/11118523.java b/codes/Qw25526/11118523.java new file mode 100644 index 0000000000000000000000000000000000000000..2289d8d3c812b3aecf7020370a798acfdcad1bcb --- /dev/null +++ b/codes/Qw25526/11118523.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/Renswc/15592706.java b/codes/Renswc/15592706.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/Renswc/15592706.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/S19353041250/15722104.java b/codes/S19353041250/15722104.java new file mode 100644 index 0000000000000000000000000000000000000000..f9a5325479d5d92111254a6775f3a8ad89cd6c83 --- /dev/null +++ b/codes/S19353041250/15722104.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * 遍历数组,比较相邻元素,如果顺序错误则交换它们,重复这个过程直到没有需要交换的元素为止。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 标志位,用于标记本趟是否有交换,如果没有交换则已经有序,无需再继续比较 + boolean swapped = false; + 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; + // 发生了交换,标志位设为true + swapped = true; + } + } + // 如果没有交换,则说明数组已经有序,无需继续后面的趟 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/SHALRU/15632282.java b/codes/SHALRU/15632282.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/SHALRU/15632282.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Sakura125809/15297826.java b/codes/Sakura125809/15297826.java new file mode 100644 index 0000000000000000000000000000000000000000..ada5cf3647b2fbe0a37eed18ae5227ed027ed4de --- /dev/null +++ b/codes/Sakura125809/15297826.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/ShaoXuan/12173130.java b/codes/ShaoXuan/12173130.java new file mode 100644 index 0000000000000000000000000000000000000000..689a8ca697591e6912972a93b43f62701255e690 --- /dev/null +++ b/codes/ShaoXuan/12173130.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + //你的代码,使无序数组 a 变得有序 + int temp = 0; + + for(int i=0; i a[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} diff --git a/codes/Sharpery/15562912.java b/codes/Sharpery/15562912.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Sharpery/15562912.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/SherlockZ/10666019.java b/codes/SherlockZ/10666019.java new file mode 100644 index 0000000000000000000000000000000000000000..ab3d8f390cfa4cee1947d39872e75bac48b3058a --- /dev/null +++ b/codes/SherlockZ/10666019.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/Shirley1/11532521.java b/codes/Shirley1/11532521.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/Shirley1/11532521.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/ShowBuger/11475929.java b/codes/ShowBuger/11475929.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/ShowBuger/11475929.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/SmileWen/15629004.java b/codes/SmileWen/15629004.java new file mode 100644 index 0000000000000000000000000000000000000000..eb07640e6f61d4fcc7a225a2235da622a7f5ca3b --- /dev/null +++ b/codes/SmileWen/15629004.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * 该函数实现了冒泡排序算法,将数组a中的元素按升序排列 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + // 遍历所有数组元素 + for (int i = 0; i < n - 1; i++) { + // 标记变量,用于检查是否发生了交换 + boolean swapped = false; + 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; + // 标记已发生交换 + swapped = true; + } + } + // 如果内层循环没有发生交换,说明数组已经有序,可以提前退出 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/Snngulaf/15527734.java b/codes/Snngulaf/15527734.java new file mode 100644 index 0000000000000000000000000000000000000000..b9f3f205791836ed8f2cbe07ba9344f6c861b74b --- /dev/null +++ b/codes/Snngulaf/15527734.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Springboot/11121747.java b/codes/Springboot/11121747.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/Springboot/11121747.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/StorIesc/11471295.java b/codes/StorIesc/11471295.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/StorIesc/11471295.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/String/11118586.java b/codes/String/11118586.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/String/11118586.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/TCplcker/11207395.java b/codes/TCplcker/11207395.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/TCplcker/11207395.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/TIANGESEC/15563393.java b/codes/TIANGESEC/15563393.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/TIANGESEC/15563393.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/TJ0000/15529221.java b/codes/TJ0000/15529221.java new file mode 100644 index 0000000000000000000000000000000000000000..a833d8d31b2581029ab106b60f560dd2c73ff238 --- /dev/null +++ b/codes/TJ0000/15529221.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + //System.out.println(a); + +} //end \ No newline at end of file diff --git a/codes/TPL666/11306800.java b/codes/TPL666/11306800.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/TPL666/11306800.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/TXMQQ4/15716488.java b/codes/TXMQQ4/15716488.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/TXMQQ4/15716488.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/TYboy2/11228569.java b/codes/TYboy2/11228569.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/TYboy2/11228569.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Tianxuan/11468972.java b/codes/Tianxuan/11468972.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/Tianxuan/11468972.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Tomorrowed/11451791.java b/codes/Tomorrowed/11451791.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/Tomorrowed/11451791.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/TonyStark_/15684919.java b/codes/TonyStark_/15684919.java new file mode 100644 index 0000000000000000000000000000000000000000..fa8593fd4989ca90711a8dbddc0367b9e453f658 --- /dev/null +++ b/codes/TonyStark_/15684919.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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]) { + // 交换 a[j] 和 a[j + 1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + +} diff --git a/codes/Tory666/11472343.java b/codes/Tory666/11472343.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/Tory666/11472343.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Tptogiar/10332054.java b/codes/Tptogiar/10332054.java new file mode 100644 index 0000000000000000000000000000000000000000..82b73c8ff8181a822b4e5b9b4a74866761c7b1ca --- /dev/null +++ b/codes/Tptogiar/10332054.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end + diff --git a/codes/UMide9/11292872.java b/codes/UMide9/11292872.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/UMide9/11292872.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/UsoDtst/.keep b/codes/UsoDtst/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/UsoDtst/11120436.java b/codes/UsoDtst/11120436.java new file mode 100644 index 0000000000000000000000000000000000000000..6def3d9364e5f1bc766dcc7ae818e0e1f242e3a7 --- /dev/null +++ b/codes/UsoDtst/11120436.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Vanish/15774749.java b/codes/Vanish/15774749.java new file mode 100644 index 0000000000000000000000000000000000000000..805879bb96b942df16f10aa4bc7c2ba291d810e5 --- /dev/null +++ b/codes/Vanish/15774749.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 功能:对数组进行升序排序 + * @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 diff --git a/codes/VincentHuang218/11469479.java b/codes/VincentHuang218/11469479.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/VincentHuang218/11469479.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/W2045396389/15630059.java b/codes/W2045396389/15630059.java new file mode 100644 index 0000000000000000000000000000000000000000..3c660dce0323e976cb42e28f96639ba405d8349f --- /dev/null +++ b/codes/W2045396389/15630059.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * 通过比较相邻的元素并交换它们的位置,如果它们的顺序错误就把它们交换过来。 + * 遍历数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 用于标记数组是否已经有序,如果某次循环中没有发生交换,则说明已经有序 + boolean isSorted = true; + 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; + // 标记数组在本次循环中发生了交换,因此数组还未有序 + isSorted = false; + } + } + // 如果在一次循环中没有发生任何交换,则数组已经有序,可以提前结束排序 + if (isSorted) { + break; + } + } +} //end diff --git a/codes/WML321/15517626.java b/codes/WML321/15517626.java new file mode 100644 index 0000000000000000000000000000000000000000..e55c540a4cba34b5207c25070adaa4dfcef3ad1d --- /dev/null +++ b/codes/WML321/15517626.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } +} //end diff --git a/codes/WQ18355919568/15742272.java b/codes/WQ18355919568/15742272.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/WQ18355919568/15742272.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/Weiyi888/.keep b/codes/Weiyi888/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Weiyi888/15720599.java b/codes/Weiyi888/15720599.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/Weiyi888/15720599.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/Whk15038723546/15482712.java b/codes/Whk15038723546/15482712.java new file mode 100644 index 0000000000000000000000000000000000000000..f521686d96958e1e609e19ccd92a74882dd295c0 --- /dev/null +++ b/codes/Whk15038723546/15482712.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } + +} //end diff --git a/codes/Wilmothe/15592034.java b/codes/Wilmothe/15592034.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/Wilmothe/15592034.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/Winnie/.keep b/codes/Winnie/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Winnie/10042948.java b/codes/Winnie/10042948.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/Winnie/10042948.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/Wiseung/15774607.java b/codes/Wiseung/15774607.java new file mode 100644 index 0000000000000000000000000000000000000000..091707ae59ea77b0b8515b267a26921754e8e5a4 --- /dev/null +++ b/codes/Wiseung/15774607.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 该函数将给定的数组进行冒泡排序,使其从小到大有序 + * @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 - 1 - i; j++) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + // 当所有循环结束后,数组a已经变得有序 +} //end diff --git a/codes/WpWwangpeng/.keep b/codes/WpWwangpeng/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/WpWwangpeng/10039890.java b/codes/WpWwangpeng/10039890.java new file mode 100644 index 0000000000000000000000000000000000000000..29d27043d3c8103739e7a1d2a27e77b4cc475876 --- /dev/null +++ b/codes/WpWwangpeng/10039890.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 diff --git a/codes/Wybzshuai/.keep b/codes/Wybzshuai/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Wybzshuai/10980502.java b/codes/Wybzshuai/10980502.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/Wybzshuai/10980502.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/XUANAIQ/15635606.java b/codes/XUANAIQ/15635606.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/XUANAIQ/15635606.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/XUEMAO/15513347.java b/codes/XUEMAO/15513347.java new file mode 100644 index 0000000000000000000000000000000000000000..e8795f9ac9fc69d87b876b78fd64eba70f441a4a --- /dev/null +++ b/codes/XUEMAO/15513347.java @@ -0,0 +1,29 @@ +/** + * 冒泡排序函数 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + if (a == null || n <= 1) { + return; // 如果数组为空或只有一个元素,不需要排序 + } + boolean swapped; + for (int i = 0; i < n - 1; i++) { + swapped = false; + 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; + swapped = true; + } + } + // 如果这一轮没有发生任何交换,说明数组已经排序完毕,可以直接退出 + if (!swapped) { + break; + } + } +} //end + + diff --git a/codes/XXOPQQ/11202216.java b/codes/XXOPQQ/11202216.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/XXOPQQ/11202216.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/XiaoBoBo/15528811.java b/codes/XiaoBoBo/15528811.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/XiaoBoBo/15528811.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/XiaoYu/15641195.java b/codes/XiaoYu/15641195.java new file mode 100644 index 0000000000000000000000000000000000000000..2a7f382c5dc5e28c56c6dd4422b8cc406318849f --- /dev/null +++ b/codes/XiaoYu/15641195.java @@ -0,0 +1,25 @@ +/** + * 冒泡排序函数 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 标志位,表示这一趟是否有交换,优化冒泡排序的关键 + boolean swapped = false; + 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; + // 发生了交换,将标志位设为true + swapped = true; + } + } + // 如果这一趟没有发生交换,说明数组已经有序,直接退出循环 + if (!swapped) { + break; + } + } +} diff --git a/codes/Y158505/.keep b/codes/Y158505/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Y158505/10040580.java b/codes/Y158505/10040580.java new file mode 100644 index 0000000000000000000000000000000000000000..29d27043d3c8103739e7a1d2a27e77b4cc475876 --- /dev/null +++ b/codes/Y158505/10040580.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 diff --git a/codes/YYDS2023/11094401.java b/codes/YYDS2023/11094401.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/YYDS2023/11094401.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/Yangtzev/15774600.java b/codes/Yangtzev/15774600.java new file mode 100644 index 0000000000000000000000000000000000000000..e73d1592940e8cb5b8cd35c8f73c6560fe4863b4 --- /dev/null +++ b/codes/Yangtzev/15774600.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过比较相邻元素的大小,并互换位置,从而达到排序的目的 + * @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 - 1 - i; j++) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/Yefori/15536426.java b/codes/Yefori/15536426.java new file mode 100644 index 0000000000000000000000000000000000000000..008f3f82dae78c0f948172175e08fed7bf68f066 --- /dev/null +++ b/codes/Yefori/15536426.java @@ -0,0 +1,29 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + // 遍历数组 + for (int i = 0; i < n; i++) { + // 设置一个标志,用于优化(如果在一次遍历中没有发生交换,说明数组已经有序,可以提前结束排序) + boolean flag = false; + // 内层循环,从第一个元素到第 n-i-1 个元素 + 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; + // 发生了交换,标志设为 true + flag = true; + } + } + // 如果在一次遍历中没有发生交换,说明数组已经有序,可以提前结束排序 + if (!flag) { + break; + } + } +} //end diff --git a/codes/Yefori/15536527.java b/codes/Yefori/15536527.java new file mode 100644 index 0000000000000000000000000000000000000000..008f3f82dae78c0f948172175e08fed7bf68f066 --- /dev/null +++ b/codes/Yefori/15536527.java @@ -0,0 +1,29 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + // 遍历数组 + for (int i = 0; i < n; i++) { + // 设置一个标志,用于优化(如果在一次遍历中没有发生交换,说明数组已经有序,可以提前结束排序) + boolean flag = false; + // 内层循环,从第一个元素到第 n-i-1 个元素 + 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; + // 发生了交换,标志设为 true + flag = true; + } + } + // 如果在一次遍历中没有发生交换,说明数组已经有序,可以提前结束排序 + if (!flag) { + break; + } + } +} //end diff --git a/codes/YixinTian/11315888.java b/codes/YixinTian/11315888.java new file mode 100644 index 0000000000000000000000000000000000000000..c1e52c76eddf689b2b4af7ce618e0e9f0bb0dcd5 --- /dev/null +++ b/codes/YixinTian/11315888.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; 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 diff --git a/codes/Yuan10001/15307047.java b/codes/Yuan10001/15307047.java new file mode 100644 index 0000000000000000000000000000000000000000..c005e4d174be10ec48d144f45ef63db8e394ce90 --- /dev/null +++ b/codes/Yuan10001/15307047.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + //外部循环控制排序的趟数。冒泡排序的每一趟会将最大的元素"冒泡"到数组的末尾,因此需要执行 n-1 趟,其中 n 是元素的总数 + for (int i = 0; i < n - 1; i++) { + //内循环控制每趟比较的次数。由于每一趟都会将一个最大的元素沉到数组末尾,所以内循环次数逐渐减小。 + for (int j = 0; j < n - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换arr[j]和arr[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + + +} //end diff --git a/codes/Yuan_559/10716235.java b/codes/Yuan_559/10716235.java new file mode 100644 index 0000000000000000000000000000000000000000..84cdc57023f796e010fc6b03591953ec3d021c7f --- /dev/null +++ b/codes/Yuan_559/10716235.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int aa=0; aaa[bb+1]) { + int cc = a[bb]; + a[bb] = a[bb+1]; + a[bb+1] = cc; + } + } + } +} //end diff --git a/codes/Z18182089257/15541298.java b/codes/Z18182089257/15541298.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/Z18182089257/15541298.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/Z1831847001/.keep b/codes/Z1831847001/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Z1831847001/10985387.java b/codes/Z1831847001/10985387.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/Z1831847001/10985387.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/Z3608759124/.keep b/codes/Z3608759124/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/Z3608759124/10979186.java b/codes/Z3608759124/10979186.java new file mode 100644 index 0000000000000000000000000000000000000000..5edd6bf0e38372fd1654da46aeafd4941c42ddb7 --- /dev/null +++ b/codes/Z3608759124/10979186.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Z3n1th/15536338.java b/codes/Z3n1th/15536338.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/Z3n1th/15536338.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/ZhangKai/11036581.java b/codes/ZhangKai/11036581.java new file mode 100644 index 0000000000000000000000000000000000000000..25d28ba464c4387da28ee5ccecb14ee67ec15321 --- /dev/null +++ b/codes/ZhangKai/11036581.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/Zhangzy/15657994.java b/codes/Zhangzy/15657994.java new file mode 100644 index 0000000000000000000000000000000000000000..4d760467cc7d134525c843bfd461de5ed858843a --- /dev/null +++ b/codes/Zhangzy/15657994.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 将数组 a 按照升序排列 + * @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 diff --git a/codes/ZoeLeo010/15732573.java b/codes/ZoeLeo010/15732573.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec373aee12c8b4795c0d670e772620e90ee630e --- /dev/null +++ b/codes/ZoeLeo010/15732573.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/a04040404/15774714.java b/codes/a04040404/15774714.java new file mode 100644 index 0000000000000000000000000000000000000000..568adf0f4624729237ac79895a66f2c6d0101637 --- /dev/null +++ b/codes/a04040404/15774714.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * 通过重复地遍历待排序的数组,比较每对相邻的元素,如果它们的顺序错误就把它们交换过来。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 标记变量,用于优化,如果在一趟排序中没有发生交换,则说明已经有序 + boolean swapped = false; + 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; + // 发生了交换,将标记设为true + swapped = true; + } + } + // 如果在一趟排序中没有发生交换,则数组已经有序,跳出循环 + if (!swapped) { + break; + } + } +} // end diff --git a/codes/a1034852656/.keep b/codes/a1034852656/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/a1034852656/10993428.java b/codes/a1034852656/10993428.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/a1034852656/10993428.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/a18370978367/15620229.java b/codes/a18370978367/15620229.java new file mode 100644 index 0000000000000000000000000000000000000000..462bdb84d30a2b7c0d01f9f6822e460a63dd9b1d --- /dev/null +++ b/codes/a18370978367/15620229.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/a18377237158/.keep b/codes/a18377237158/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/a18377237158/10978793.java b/codes/a18377237158/10978793.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/a18377237158/10978793.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/a2159028620/.keep b/codes/a2159028620/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/a2159028620/10980184.java b/codes/a2159028620/10980184.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/a2159028620/10980184.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/a2313064922/15679065.java b/codes/a2313064922/15679065.java new file mode 100644 index 0000000000000000000000000000000000000000..e67491fe620b2cf2e4e6ad2265d990c0472c8a14 --- /dev/null +++ b/codes/a2313064922/15679065.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 这是一个简单的排序算法,通过重复遍历要排序的列表,比较每对相邻的项,如果它们的顺序错误就把它们交换过来。 + * @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 diff --git a/codes/a2523760784/9941105.java b/codes/a2523760784/9941105.java new file mode 100644 index 0000000000000000000000000000000000000000..5220eb8d8b2c6eb8beb6c8ae9207d00e4484d77b --- /dev/null +++ b/codes/a2523760784/9941105.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + if(a == null || a.length == 0){ + return; + } + for(int i = 0; i< n; i++){ + boolean flag = true; + for(int j = 0; j< n - i - 1 ; j++){ + if(a[j]> a[j+1]){ + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + flag = false; + } + } + if(flag){ + break; + } + + } +} //end diff --git a/codes/a2554028123/.keep b/codes/a2554028123/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/a2554028123/10984030.java b/codes/a2554028123/10984030.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/a2554028123/10984030.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/a940959221/15733763.java b/codes/a940959221/15733763.java new file mode 100644 index 0000000000000000000000000000000000000000..ee68c90a81978415c1c6355448aab377e4cfc17b --- /dev/null +++ b/codes/a940959221/15733763.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 对数组a进行升序排序 + * @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]) { + // 交换a[j]和a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/aAuely/15714122.java b/codes/aAuely/15714122.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/aAuely/15714122.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/aaa_zzz/15684144.java b/codes/aaa_zzz/15684144.java new file mode 100644 index 0000000000000000000000000000000000000000..269aafa3267f08275e184d1a0aab16a23c023158 --- /dev/null +++ b/codes/aaa_zzz/15684144.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 该函数会对数组a进行排序,使其变为有序数组 + * @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 - 1 - i; j++) { // 内层循环控制每一趟排序多少次 + if (a[j] > a[j + 1]) { // 如果前一个数比后一个数大,则交换这两个数 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/aas123/15713924.java b/codes/aas123/15713924.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/aas123/15713924.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/aass123/15720115.java b/codes/aass123/15720115.java new file mode 100644 index 0000000000000000000000000000000000000000..d29bb658b4e62d5429b6138e82644337724ef934 --- /dev/null +++ b/codes/aass123/15720115.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy \ No newline at end of file diff --git a/codes/abaoge/15684921.java b/codes/abaoge/15684921.java new file mode 100644 index 0000000000000000000000000000000000000000..634b7859dbe3a58fbc8d6e049519ebf357b354e4 --- /dev/null +++ b/codes/abaoge/15684921.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 通过不断比较相邻元素的大小,将较大的元素逐步“浮”到数组的末尾,从而实现排序。 + * @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 - 1 - i; j++) { // 内层循环,负责相邻元素间的比较和交换 + if (a[j] > a[j + 1]) { // 如果当前元素大于下一个元素,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/abaper/.keep b/codes/abaper/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/abaper/10978249.java b/codes/abaper/10978249.java new file mode 100644 index 0000000000000000000000000000000000000000..862a031b6f73aac6e6e6656df710e9caa439d4c0 --- /dev/null +++ b/codes/abaper/10978249.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int m=0 ; ma[q+1]) { + int temp=a[q]; + a[q]=a[q+1]; + a[q+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/acc8226/15757227.java b/codes/acc8226/15757227.java new file mode 100644 index 0000000000000000000000000000000000000000..1c380514cd45df67d80b478bce94df566216be5f --- /dev/null +++ b/codes/acc8226/15757227.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n) { + int temp; + for (int i = 1; i < n; i++) { + for (int j = 0; j < n - i; j++) { + if (a[j] > a[j + 1]) { + temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + // 你的代码,使无序数组 a 变得有序 +} diff --git a/codes/acloudio/11274672.java b/codes/acloudio/11274672.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/acloudio/11274672.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/activemy/14206633.java b/codes/activemy/14206633.java new file mode 100644 index 0000000000000000000000000000000000000000..002e3d165b2e990cda107240294f91670a872f05 --- /dev/null +++ b/codes/activemy/14206633.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有 + if (0 >= n) + { + return; + } + int tmp,i,j; + for (j=n-1; j>0; j--) + { + for (i=0; i a[i+1]) + { + tmp = a[i+1]; + a[i+1] = a[i]; + a[i] = tmp; + } + } + } + return; + +} //end diff --git a/codes/addqian/14612723.java b/codes/addqian/14612723.java new file mode 100644 index 0000000000000000000000000000000000000000..3daf885d258d5c71ac1f3467e62151044f13c070 --- /dev/null +++ b/codes/addqian/14612723.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + int changeFlag; + for (int i = 0; i < n - 1; i++) { + changeFlag = 0; + for (int j = 0; j < n - i - 1; ++j) { + if (a[j] > a[j + 1]) { + a[j] ^= a[j + 1]; + a[j + 1] ^= a[j]; + a[j] ^= a[j + 1]; + changeFlag = 1; + } + } + if (changeFlag == 0) { + break; + } + } +} //end + diff --git a/codes/address/11226902.java b/codes/address/11226902.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/address/11226902.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/admin228855/10967397.java b/codes/admin228855/10967397.java new file mode 100644 index 0000000000000000000000000000000000000000..deb2438785c696d09e985c35997c2f2bc5445a90 --- /dev/null +++ b/codes/admin228855/10967397.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/adminuser/10040823.java b/codes/adminuser/10040823.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/adminuser/10040823.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/adsf45362/.keep b/codes/adsf45362/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/adsf45362/15743460.java b/codes/adsf45362/15743460.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/adsf45362/15743460.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/af345sdga/.keep b/codes/af345sdga/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/af345sdga/15743439.java b/codes/af345sdga/15743439.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/af345sdga/15743439.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/afasfasf24214/.keep b/codes/afasfasf24214/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/afasfasf24214/15743480.java b/codes/afasfasf24214/15743480.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/afasfasf24214/15743480.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/aikun66/15577937.java b/codes/aikun66/15577937.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/aikun66/15577937.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/alchemists/.keep b/codes/alchemists/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/alchemists/15772130.java b/codes/alchemists/15772130.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/alchemists/15772130.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/amoxilin/15519580.java b/codes/amoxilin/15519580.java new file mode 100644 index 0000000000000000000000000000000000000000..c2ba699c076fe8d3236794c7d4528ef22f66bb28 --- /dev/null +++ b/codes/amoxilin/15519580.java @@ -0,0 +1,12 @@ +public static void bubbleSort(int [] a, int n){ + 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; + } + } + } + +} diff --git a/codes/an629712562/.keep b/codes/an629712562/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/an629712562/15629207.java b/codes/an629712562/15629207.java new file mode 100644 index 0000000000000000000000000000000000000000..7a18dd82cbeb41d84bf819d91c39abcbb9758f55 --- /dev/null +++ b/codes/an629712562/15629207.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int an = 0; an < n - i - 1; an++) { + if(a[an] > a[an + 1]) { + int temp = a[an]; + a [an] = a[an + 1]; + a[an + 1] = temp; + } + } + } + + +} //end,an \ No newline at end of file diff --git a/codes/angel521/15721117.java b/codes/angel521/15721117.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/angel521/15721117.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/anqi12301/15532075.java b/codes/anqi12301/15532075.java new file mode 100644 index 0000000000000000000000000000000000000000..b9f3f205791836ed8f2cbe07ba9344f6c861b74b --- /dev/null +++ b/codes/anqi12301/15532075.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/argument/11235878.java b/codes/argument/11235878.java new file mode 100644 index 0000000000000000000000000000000000000000..deb2438785c696d09e985c35997c2f2bc5445a90 --- /dev/null +++ b/codes/argument/11235878.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/aria111/.keep b/codes/aria111/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/aria111/10043458.java b/codes/aria111/10043458.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/aria111/10043458.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/arvinsblog/15525225.java b/codes/arvinsblog/15525225.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/arvinsblog/15525225.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/as1234567890/.keep b/codes/as1234567890/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/as1234567890/10979740.java b/codes/as1234567890/10979740.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/as1234567890/10979740.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/asdafcv22/.keep b/codes/asdafcv22/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/asdafcv22/15742508.java b/codes/asdafcv22/15742508.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/asdafcv22/15742508.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/asen_1898/15541357.java b/codes/asen_1898/15541357.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/asen_1898/15541357.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/asf435adf/.keep b/codes/asf435adf/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/asf435adf/15743462.java b/codes/asf435adf/15743462.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/asf435adf/15743462.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/asfasfa22/.keep b/codes/asfasfa22/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/asfasfa22/15742636.java b/codes/asfasfa22/15742636.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/asfasfa22/15742636.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/asffasf67/.keep b/codes/asffasf67/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/asffasf67/15743465.java b/codes/asffasf67/15743465.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/asffasf67/15743465.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/asfsafaf223/.keep b/codes/asfsafaf223/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/asfsafaf223/15743410.java b/codes/asfsafaf223/15743410.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/asfsafaf223/15743410.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/avania/14344405.java b/codes/avania/14344405.java new file mode 100644 index 0000000000000000000000000000000000000000..6115f0ce1ea819bc98cdd13856a7b2619b01db61 --- /dev/null +++ b/codes/avania/14344405.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; ++j){ + if(a[j] > a[j+1]){ + int k = a[j]; + a[j] = a[j+1]; + a[j+1] = k; + } + } + } +} //end diff --git a/codes/azhen666/15569325.java b/codes/azhen666/15569325.java new file mode 100644 index 0000000000000000000000000000000000000000..8fa7ad575a3fe44df4708be30eddab3ad58f6147 --- /dev/null +++ b/codes/azhen666/15569325.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 通过重复地遍历要排序的数组,比较每对相邻的元素,并在必要时交换它们的位置, + * 遍历数组的工作是重复地进行直到没有再需要交换,也就是说该数组已经排序完成。 + * @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]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/b1t333/12428176.java b/codes/b1t333/12428176.java new file mode 100644 index 0000000000000000000000000000000000000000..6a52fcd0769f4ebb66b54603d5d70f944c4fe600 --- /dev/null +++ b/codes/b1t333/12428176.java @@ -0,0 +1,36 @@ + +/* + * SonarQube,开源软件质量管理工具。 + * 版权所有 (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 是免费软件;您可以重新分发它和/或 + * 根据 GNU Lesser General Public 的条款修改它 + * 由自由软件基金会发布的许可证; + * 许可证的第 3 版,或(由您选择)任何更高版本。 + * + * 分发 SonarQube 是为了希望它有用, + * 但没有任何保证;甚至没有 + * 适销性或适用于特定目的的暗示保证。有关详细信息,请参阅 GNU + * 宽松通用公共许可证。 + * + * 您应该已经收到一份 GNU 宽松通用公共许可证的副本 + * 以及此程序;如果没有,请写信给自由软件基金会, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA。 + */ + public static void bubbleSort(int [] a, int n) + { + 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; + } + } + } + } + diff --git a/codes/b2247960736/15520708.java b/codes/b2247960736/15520708.java new file mode 100644 index 0000000000000000000000000000000000000000..72e12e15a127c15b0f77a113cb8f811237348f7c --- /dev/null +++ b/codes/b2247960736/15520708.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 diff --git a/codes/bIU999lve/.keep b/codes/bIU999lve/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/bIU999lve/11090549.java b/codes/bIU999lve/11090549.java new file mode 100644 index 0000000000000000000000000000000000000000..29d27043d3c8103739e7a1d2a27e77b4cc475876 --- /dev/null +++ b/codes/bIU999lve/11090549.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 diff --git a/codes/baixiaobai/15198492.java b/codes/baixiaobai/15198492.java new file mode 100644 index 0000000000000000000000000000000000000000..e9ed4eae2a9d51ed8bc197666a445432f8e44921 --- /dev/null +++ b/codes/baixiaobai/15198492.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] < a[j + 1]) { + continue; + } + // 如果前一个元素比后一个元素大,则交换两者 + int temp = a[j + 1]; + a[j + 1] = a[j]; + a[j] = temp; + } + } +} //end \ No newline at end of file diff --git a/codes/baixiaobai/15198733.java b/codes/baixiaobai/15198733.java new file mode 100644 index 0000000000000000000000000000000000000000..e9ed4eae2a9d51ed8bc197666a445432f8e44921 --- /dev/null +++ b/codes/baixiaobai/15198733.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] < a[j + 1]) { + continue; + } + // 如果前一个元素比后一个元素大,则交换两者 + int temp = a[j + 1]; + a[j + 1] = a[j]; + a[j] = temp; + } + } +} //end \ No newline at end of file diff --git a/codes/baixiaobai/15198745.java b/codes/baixiaobai/15198745.java new file mode 100644 index 0000000000000000000000000000000000000000..e9ed4eae2a9d51ed8bc197666a445432f8e44921 --- /dev/null +++ b/codes/baixiaobai/15198745.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] < a[j + 1]) { + continue; + } + // 如果前一个元素比后一个元素大,则交换两者 + int temp = a[j + 1]; + a[j + 1] = a[j]; + a[j] = temp; + } + } +} //end \ No newline at end of file diff --git a/codes/baixiaobai/15199487.java b/codes/baixiaobai/15199487.java new file mode 100644 index 0000000000000000000000000000000000000000..e9ed4eae2a9d51ed8bc197666a445432f8e44921 --- /dev/null +++ b/codes/baixiaobai/15199487.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] < a[j + 1]) { + continue; + } + // 如果前一个元素比后一个元素大,则交换两者 + int temp = a[j + 1]; + a[j + 1] = a[j]; + a[j] = temp; + } + } +} //end \ No newline at end of file diff --git a/codes/bc521bc/9954342.java b/codes/bc521bc/9954342.java new file mode 100644 index 0000000000000000000000000000000000000000..82b73c8ff8181a822b4e5b9b4a74866761c7b1ca --- /dev/null +++ b/codes/bc521bc/9954342.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end + diff --git a/codes/bc99991/11118867.java b/codes/bc99991/11118867.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/bc99991/11118867.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/bei123/15714125.java b/codes/bei123/15714125.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/bei123/15714125.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/benben/15721436.java b/codes/benben/15721436.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/benben/15721436.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/bertao/11204465.java b/codes/bertao/11204465.java new file mode 100644 index 0000000000000000000000000000000000000000..25d28ba464c4387da28ee5ccecb14ee67ec15321 --- /dev/null +++ b/codes/bertao/11204465.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/bic-omg/.keep b/codes/bic-omg/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/bic-omg/10972075.java b/codes/bic-omg/10972075.java new file mode 100644 index 0000000000000000000000000000000000000000..c93923d8fc4260fe1fe393c3461b1320aae87f95 --- /dev/null +++ b/codes/bic-omg/10972075.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/bigDog/11298506.java b/codes/bigDog/11298506.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/bigDog/11298506.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/bitexplorers/.keep b/codes/bitexplorers/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/bitexplorers/15774316.java b/codes/bitexplorers/15774316.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/bitexplorers/15774316.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/blackgaryc/14345942.java b/codes/blackgaryc/14345942.java new file mode 100644 index 0000000000000000000000000000000000000000..3db39fd1c51220854380ea76eeb72e22cd680bb5 --- /dev/null +++ b/codes/blackgaryc/14345942.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end diff --git a/codes/bless_qian/15628082.java b/codes/bless_qian/15628082.java new file mode 100644 index 0000000000000000000000000000000000000000..f1b0ff6158ae2480d9a87f72d07999c5f92df1b1 --- /dev/null +++ b/codes/bless_qian/15628082.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 将数组a从小到大进行排序 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n; 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; + } + } + } +} + diff --git a/codes/blingpotato/15623762.java b/codes/blingpotato/15623762.java new file mode 100644 index 0000000000000000000000000000000000000000..6bdd05fcc4de29678709e7f6b5e0ea65b586d80b --- /dev/null +++ b/codes/blingpotato/15623762.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过相邻元素之间的比较和交换,将数组排序为升序 + * @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 - 1 - i; j++) { // 内层循环控制每一趟排序多少次 + if (a[j] > a[j + 1]) { // 如果前一个元素比后一个元素大,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/blockup/15585762.java b/codes/blockup/15585762.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/blockup/15585762.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/bmyy111/15635777.java b/codes/bmyy111/15635777.java new file mode 100644 index 0000000000000000000000000000000000000000..04625a494ce3da760397a3c3c648cdbe5d0bfa71 --- /dev/null +++ b/codes/bmyy111/15635777.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end + diff --git a/codes/book123/15699999.java b/codes/book123/15699999.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/book123/15699999.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/bopiox/11219150.java b/codes/bopiox/11219150.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/bopiox/11219150.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/budasan/11121691.java b/codes/budasan/11121691.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/budasan/11121691.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/buhuizhiyuqianduan/11245496.java b/codes/buhuizhiyuqianduan/11245496.java new file mode 100644 index 0000000000000000000000000000000000000000..6da7a74fe64b09a004a6d641ea191a7fc64f6140 --- /dev/null +++ b/codes/buhuizhiyuqianduan/11245496.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - 1 - i; j++) { + if (arr[j] > arr[j + 1]) { + int temp = arr[j]; + arr[j] = arr[j+1]; + arr[j+1] = temp; + } + } + } +} //end diff --git a/codes/bujin521/11301842.java b/codes/bujin521/11301842.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/bujin521/11301842.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/bundle/11196164.java b/codes/bundle/11196164.java new file mode 100644 index 0000000000000000000000000000000000000000..661499fc3a69b869708e75b839ddbc12a2776d9b --- /dev/null +++ b/codes/bundle/11196164.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} diff --git a/codes/bupiovm0101/11122657.java b/codes/bupiovm0101/11122657.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/bupiovm0101/11122657.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/bushioo/11276443.java b/codes/bushioo/11276443.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/bushioo/11276443.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/buzhidao/11118686.java b/codes/buzhidao/11118686.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/buzhidao/11118686.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/cai0002/15520914.java b/codes/cai0002/15520914.java new file mode 100644 index 0000000000000000000000000000000000000000..808f5412e2ca2e79231eeedaa55d778acfeb1bee --- /dev/null +++ b/codes/cai0002/15520914.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 遍历数组,比较相邻元素,将较大的元素交换到数组的末尾,重复直到整个数组有序 + * @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; + } + } + } +} diff --git a/codes/cai001/15520883.java b/codes/cai001/15520883.java new file mode 100644 index 0000000000000000000000000000000000000000..808f5412e2ca2e79231eeedaa55d778acfeb1bee --- /dev/null +++ b/codes/cai001/15520883.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 遍历数组,比较相邻元素,将较大的元素交换到数组的末尾,重复直到整个数组有序 + * @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; + } + } + } +} diff --git a/codes/caizengming/15396209.java b/codes/caizengming/15396209.java new file mode 100644 index 0000000000000000000000000000000000000000..c583260da5e1b739d67776354cb6933af3646be8 --- /dev/null +++ b/codes/caizengming/15396209.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + + for(int i = 0 ; i < n; 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 diff --git a/codes/caozhou/10869186.java b/codes/caozhou/10869186.java new file mode 100644 index 0000000000000000000000000000000000000000..0551a31e6517d6c16922f38f1aa2b9b65d7b0f03 --- /dev/null +++ b/codes/caozhou/10869186.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n){ + for(int i = 0 ; i < n - 1 ; i++){ + for(int j = 0 ; j < n - 1 - i ; j++){ + if(a[j] > a[j + 1]){ + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} diff --git a/codes/captaining/15614511.java b/codes/captaining/15614511.java new file mode 100644 index 0000000000000000000000000000000000000000..86d776a408de93103a7142ef74ccc031789b506d --- /dev/null +++ b/codes/captaining/15614511.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较并交换,使得每一轮循环后最大(或最小)的元素“冒泡”到数组的末尾 + * @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 - 1 - i; j++) { // 内层循环控制每轮需要比较的次数 + if (a[j] > a[j + 1]) { // 如果当前元素大于下一个元素,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/carino5555/15527193.java b/codes/carino5555/15527193.java new file mode 100644 index 0000000000000000000000000000000000000000..fe1a0c288940fc02b0983c37f7a4da8058bf89e0 --- /dev/null +++ b/codes/carino5555/15527193.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 对数组a进行冒泡排序,使其变为有序数组 + * @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]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/caroline/15374117.java b/codes/caroline/15374117.java new file mode 100644 index 0000000000000000000000000000000000000000..9c77b43d4a0b0734e87d3b4c380ad82c495693b9 --- /dev/null +++ b/codes/caroline/15374117.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for(int i=0;ia[j+1]) + { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/cccqqq/.keep b/codes/cccqqq/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/cccqqq/10039861.java b/codes/cccqqq/10039861.java new file mode 100644 index 0000000000000000000000000000000000000000..b18037655daf75c51c9d669c057d9a658261d6ec --- /dev/null +++ b/codes/cccqqq/10039861.java @@ -0,0 +1,17 @@ +/* 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +} //end \ No newline at end of file diff --git a/codes/ccone123/15713748.java b/codes/ccone123/15713748.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/ccone123/15713748.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/ccout0/12264632.java b/codes/ccout0/12264632.java new file mode 100644 index 0000000000000000000000000000000000000000..998bc63ed0ce64bdb06f97b596bde3ba47da68d9 --- /dev/null +++ b/codes/ccout0/12264632.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = n; i > 0; i--) { + boolean isOrderly = true; + for (int j = 0; j < i - 1; j++) { + if (a[j] > a[j + 1]) { + int t = a[j]; + a[j] = a[j + 1]; + a[j + 1] = t; + isOrderly = false; + } + } + if (isOrderly) { + break; + } + } +} diff --git a/codes/cghg547546/.keep b/codes/cghg547546/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/cghg547546/15743428.java b/codes/cghg547546/15743428.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/cghg547546/15743428.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/chanziruu/.keep b/codes/chanziruu/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/chanziruu/10042211.java b/codes/chanziruu/10042211.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/chanziruu/10042211.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/chase11/15577508.java b/codes/chase11/15577508.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/chase11/15577508.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/chenabing/15724269.java b/codes/chenabing/15724269.java new file mode 100644 index 0000000000000000000000000000000000000000..c8f31c95cb81565ebe135b7a324269913ba36b96 --- /dev/null +++ b/codes/chenabing/15724269.java @@ -0,0 +1,13 @@ +public static void bubbleSort(int []a,int n){ + int length = n; + for(int i=0;ia[j+1]){ + int temp = a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + + } + } +} diff --git a/codes/chenchen1234/15630722.java b/codes/chenchen1234/15630722.java new file mode 100644 index 0000000000000000000000000000000000000000..0028b5a068597ec8aa7515518676f257fa6b2e0c --- /dev/null +++ b/codes/chenchen1234/15630722.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 冒泡排序是一种简单的排序算法,它重复地遍历要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 + * 遍历数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。 + * @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]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/chency/15542287.java b/codes/chency/15542287.java new file mode 100644 index 0000000000000000000000000000000000000000..f186571675d133f859fc07d24a4a78ee9282ecec --- /dev/null +++ b/codes/chency/15542287.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 通过相邻元素之间的比较和交换,使得每一轮比较后最大(或最小)的元素能够“冒泡”到数组的末尾。 + * @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 - 1 - i; j++) { // 内层循环控制每轮比较的次数 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/chengchen/10039151.java b/codes/chengchen/10039151.java new file mode 100644 index 0000000000000000000000000000000000000000..fce1e8fc1bc51f5996c9c8695961eb465fa5ff67 --- /dev/null +++ b/codes/chengchen/10039151.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +} //end diff --git a/codes/chengzhi/11005917.java b/codes/chengzhi/11005917.java new file mode 100644 index 0000000000000000000000000000000000000000..661499fc3a69b869708e75b839ddbc12a2776d9b --- /dev/null +++ b/codes/chengzhi/11005917.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} diff --git a/codes/chenhan1129/15542140.java b/codes/chenhan1129/15542140.java new file mode 100644 index 0000000000000000000000000000000000000000..2c70a5f0a8a7f03f7f386683b93f02bf6ebec03e --- /dev/null +++ b/codes/chenhan1129/15542140.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 该函数使用冒泡排序算法对数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/chenyongru/.keep b/codes/chenyongru/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/chenyongru/15764377.java b/codes/chenyongru/15764377.java new file mode 100644 index 0000000000000000000000000000000000000000..d40803fb8fd6db6216a346341ff5180f0b773922 --- /dev/null +++ b/codes/chenyongru/15764377.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/chris2024/15600397.java b/codes/chris2024/15600397.java new file mode 100644 index 0000000000000000000000000000000000000000..2252b818e6125ed4f8bbd23eca03c12c15ca1757 --- /dev/null +++ b/codes/chris2024/15600397.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/chuyuxuan/15685256.java b/codes/chuyuxuan/15685256.java new file mode 100644 index 0000000000000000000000000000000000000000..137560e5ef1657b2bb8a51599b746d7b9dd29d14 --- /dev/null +++ b/codes/chuyuxuan/15685256.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 通过多次遍历数组,比较相邻元素的大小,并交换它们的位置, + * 直到没有需要交换的元素为止,从而使得数组有序。 + * @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 - 1 - i; j++) { // 内层循环控制每次遍历比较的次数 + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/clausliang/11466217.java b/codes/clausliang/11466217.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/clausliang/11466217.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/cloudchasers/.keep b/codes/cloudchasers/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/cloudchasers/15772624.java b/codes/cloudchasers/15772624.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/cloudchasers/15772624.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/cly2589/15577808.java b/codes/cly2589/15577808.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/cly2589/15577808.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/coco08/11244510.java b/codes/coco08/11244510.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/coco08/11244510.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/codeelite/.keep b/codes/codeelite/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/codeelite/15774516.java b/codes/codeelite/15774516.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/codeelite/15774516.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/codeshallow/.java b/codes/codeshallow/.java new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/codeshallow/9947400.java b/codes/codeshallow/9947400.java new file mode 100644 index 0000000000000000000000000000000000000000..10dbc6525b8c4427dda5055b3f3c224c68398d2c --- /dev/null +++ b/codes/codeshallow/9947400.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end diff --git a/codes/comTom/10859102.java b/codes/comTom/10859102.java new file mode 100644 index 0000000000000000000000000000000000000000..ab3d8f390cfa4cee1947d39872e75bac48b3058a --- /dev/null +++ b/codes/comTom/10859102.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/conanz/.keep b/codes/conanz/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/conanz/10041693.java b/codes/conanz/10041693.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/conanz/10041693.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/coo6666/11212756.java b/codes/coo6666/11212756.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/coo6666/11212756.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/coolbob/11342463.java b/codes/coolbob/11342463.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/coolbob/11342463.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/coreliu/9889405.java b/codes/coreliu/9889405.java new file mode 100644 index 0000000000000000000000000000000000000000..661499fc3a69b869708e75b839ddbc12a2776d9b --- /dev/null +++ b/codes/coreliu/9889405.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} diff --git a/codes/course/15530455.java b/codes/course/15530455.java new file mode 100644 index 0000000000000000000000000000000000000000..61c422b629e86de0017a8c4de128f6973bd290c9 --- /dev/null +++ b/codes/course/15530455.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/cppdkuo/11329887.java b/codes/cppdkuo/11329887.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/cppdkuo/11329887.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/cr12345/.keep b/codes/cr12345/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/cr12345/10985032.java b/codes/cr12345/10985032.java new file mode 100644 index 0000000000000000000000000000000000000000..ecc6b910e01246737286675ada360c1f523475f8 --- /dev/null +++ b/codes/cr12345/10985032.java @@ -0,0 +1,12 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} + diff --git a/codes/crh111/15562582.java b/codes/crh111/15562582.java new file mode 100644 index 0000000000000000000000000000000000000000..25b3bbe48bce467063cee5629079bc6a1504a0ec --- /dev/null +++ b/codes/crh111/15562582.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end diff --git a/codes/cslearn/10428388.java b/codes/cslearn/10428388.java new file mode 100644 index 0000000000000000000000000000000000000000..5ba81a6b94b820eafee5fda1bbd6ce01d9d083b4 --- /dev/null +++ b/codes/cslearn/10428388.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + +} //end diff --git a/codes/cumtsgw/.15377867.java.swp b/codes/cumtsgw/.15377867.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..50eed755d8becbd73a565f065816f9970304c3ea Binary files /dev/null and b/codes/cumtsgw/.15377867.java.swp differ diff --git a/codes/cumtsgw/15377867.java b/codes/cumtsgw/15377867.java new file mode 100644 index 0000000000000000000000000000000000000000..27626c403eaa167d0a67eb769b2c3d8c95df20dd --- /dev/null +++ b/codes/cumtsgw/15377867.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; 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; + } + } + } +} //end diff --git a/codes/current/11226352.java b/codes/current/11226352.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/current/11226352.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/cursor/.java b/codes/cursor/.java new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/cursor/13859449.java b/codes/cursor/13859449.java new file mode 100644 index 0000000000000000000000000000000000000000..6fbfba637d03d4f83c986e9c02a37a624268bd6a --- /dev/null +++ b/codes/cursor/13859449.java @@ -0,0 +1,33 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + if (n <= 1) { + return; + } + + for (int i = 0; i < n; i++) { + // 提前退出冒泡循环的标志位 + boolean flag = false; + + 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; + // 设置标志位为true + flag = true; + } + } + + if (!flag) { // 如果一次冒泡循环中没有发生交换,则说明数组已经有序,直接退出循环 + break; + } + } + +} //end diff --git a/codes/cyanide/15311596.java b/codes/cyanide/15311596.java new file mode 100644 index 0000000000000000000000000000000000000000..2b9ca2cfd4ca60597211367f659c9aeb6cf30b10 --- /dev/null +++ b/codes/cyanide/15311596.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] arr, int n){ + for(int i = 0; i < n; 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; + } + } + } +} diff --git a/codes/cyberwarriors/.keep b/codes/cyberwarriors/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/cyberwarriors/15771923.java b/codes/cyberwarriors/15771923.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/cyberwarriors/15771923.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/cyc991026/.keep b/codes/cyc991026/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/cyc991026/10042475.java b/codes/cyc991026/10042475.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/cyc991026/10042475.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/cyrusyu/11179070.java b/codes/cyrusyu/11179070.java new file mode 100644 index 0000000000000000000000000000000000000000..183c2516b28113e5c1197a19ab0c7945d79b5d20 --- /dev/null +++ b/codes/cyrusyu/11179070.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end + diff --git a/codes/daisyw0221/15531109.java b/codes/daisyw0221/15531109.java new file mode 100644 index 0000000000000000000000000000000000000000..09f809e415a4633d026f43e5f6d9f379165fc44b --- /dev/null +++ b/codes/daisyw0221/15531109.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j + 1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/dappwwww/10999016.java b/codes/dappwwww/10999016.java new file mode 100644 index 0000000000000000000000000000000000000000..d34027face05a4c77a2a35deae63795bb9c58f79 --- /dev/null +++ b/codes/dappwwww/10999016.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + if(a == null || a.length == 0){ + return; + } + for(int i = 0; i< n; i++){ + boolean flag = true; + for(int j = 0; j< n - i - 1 ; j++){ + if(a[j]> a[j+1]){ + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + flag = false; + } + } + if(flag){ + break; + } + + } +} //end \ No newline at end of file diff --git a/codes/darkfu/15693973.java b/codes/darkfu/15693973.java new file mode 100644 index 0000000000000000000000000000000000000000..3ca2d28eb7fccbe814f3857fc11061c1324317bc --- /dev/null +++ b/codes/darkfu/15693973.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 使用冒泡法对数组进行升序排序 + * @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 - 1 - i; j++) { // 内层循环用来比较相邻元素并可能交换它们 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/dawnli/15533387.java b/codes/dawnli/15533387.java new file mode 100644 index 0000000000000000000000000000000000000000..bdd22e5b5503973ed7066b59149c51127f36664e --- /dev/null +++ b/codes/dawnli/15533387.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * 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]) { + // 交换 arr[j+1] and arr[j] + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + } //end diff --git a/codes/dayeee/12165634.java b/codes/dayeee/12165634.java new file mode 100644 index 0000000000000000000000000000000000000000..9a1b572d4ab0a76a6614137e28d90b6c2dd28ef8 --- /dev/null +++ b/codes/dayeee/12165634.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] 的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/dayuya/10044865.java b/codes/dayuya/10044865.java new file mode 100644 index 0000000000000000000000000000000000000000..83bb3cd3aa5e3e22feb4c71643b6b05d736e4b55 --- /dev/null +++ b/codes/dayuya/10044865.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/dedeya/15742795.java b/codes/dedeya/15742795.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/dedeya/15742795.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/deijia909/11468750.java b/codes/deijia909/11468750.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/deijia909/11468750.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/devinroot/9687540.java b/codes/devinroot/9687540.java new file mode 100644 index 0000000000000000000000000000000000000000..7aa905f3acb901a1a470d411df1ce71f7e107a4f --- /dev/null +++ b/codes/devinroot/9687540.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + //System.out.println(a); + +} //end diff --git a/codes/dfg56tsdfas/.keep b/codes/dfg56tsdfas/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dfg56tsdfas/15743482.java b/codes/dfg56tsdfas/15743482.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/dfg56tsdfas/15743482.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/diantun00/13629189.java b/codes/diantun00/13629189.java new file mode 100644 index 0000000000000000000000000000000000000000..66bacf1af033896dc478c2741e5828abbac347d2 --- /dev/null +++ b/codes/diantun00/13629189.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end diff --git a/codes/dioopp/11292585.java b/codes/dioopp/11292585.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/dioopp/11292585.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/dishierge/.keep b/codes/dishierge/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dishierge/15758829.java b/codes/dishierge/15758829.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/dishierge/15758829.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/dishige/.keep b/codes/dishige/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dishige/15758406.java b/codes/dishige/15758406.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/dishige/15758406.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/dishijiuge/.keep b/codes/dishijiuge/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dishijiuge/15759226.java b/codes/dishijiuge/15759226.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/dishijiuge/15759226.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/dishiliuge/.keep b/codes/dishiliuge/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dishiliuge/15759149.java b/codes/dishiliuge/15759149.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/dishiliuge/15759149.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/dishiqige/.keep b/codes/dishiqige/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dishiqige/15759140.java b/codes/dishiqige/15759140.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/dishiqige/15759140.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/dishisi/.keep b/codes/dishisi/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dishisi/15758975.java b/codes/dishisi/15758975.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/dishisi/15758975.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/dishissange/.keep b/codes/dishissange/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dishissange/15759022.java b/codes/dishissange/15759022.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/dishissange/15759022.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/dishiwuge/.keep b/codes/dishiwuge/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dishiwuge/15759050.java b/codes/dishiwuge/15759050.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/dishiwuge/15759050.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/diudiuge12262792/15499955.java b/codes/diudiuge12262792/15499955.java new file mode 100644 index 0000000000000000000000000000000000000000..68edfbccbb546b67f699c1e200d26c82a9e1f941 --- /dev/null +++ b/codes/diudiuge12262792/15499955.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n; i++) { + boolean swapped = false; + + 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; + + swapped = true; + } + } + + // 如果在整个内部循环中都没有交换,则数组已经是排序好的 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/dkptlv/15520718.java b/codes/dkptlv/15520718.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/dkptlv/15520718.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/dragg123/15718958.java b/codes/dragg123/15718958.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/dragg123/15718958.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/dragonir/11357510.java b/codes/dragonir/11357510.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/dragonir/11357510.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/dsfsqerada33/.keep b/codes/dsfsqerada33/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/dsfsqerada33/15743351.java b/codes/dsfsqerada33/15743351.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/dsfsqerada33/15743351.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/duanshusheng/15508667.java b/codes/duanshusheng/15508667.java new file mode 100644 index 0000000000000000000000000000000000000000..cea168b5c054cacc07ac29bad448fc0d73b21ff8 --- /dev/null +++ b/codes/duanshusheng/15508667.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; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[i]; + a[i] = a[j]; + a[j] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/duanxintao/15684621.java b/codes/duanxintao/15684621.java new file mode 100644 index 0000000000000000000000000000000000000000..be1beed5543eb5e66db4e4e5a75da8787a3973d3 --- /dev/null +++ b/codes/duanxintao/15684621.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较,将较大的元素交换到数组的末尾, + * 重复这个过程直到整个数组变得有序。 + * @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 - 1 - i; j++) { + // 如果前一个元素比后一个元素大,则交换它们的位置 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/dulong/11749087.java b/codes/dulong/11749087.java new file mode 100644 index 0000000000000000000000000000000000000000..1462d26235b024a7f108828a86ad58006771f6ff --- /dev/null +++ b/codes/dulong/11749087.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + if (n <= 1) return; + for (int i = 0; i < n; ++i) { + boolean flag = false; + for (int j = 0; j < n - i - 1; ++j) { + if (a[j] > a[j+1]) { + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + flag = true; + } + } + if (!flag) break; + } +} //end diff --git a/codes/duoduo172/15759065.java b/codes/duoduo172/15759065.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/duoduo172/15759065.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/duziteng/10968772.java b/codes/duziteng/10968772.java new file mode 100644 index 0000000000000000000000000000000000000000..ab3d8f390cfa4cee1947d39872e75bac48b3058a --- /dev/null +++ b/codes/duziteng/10968772.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/ebb29bbe/9945255.java b/codes/ebb29bbe/9945255.java new file mode 100644 index 0000000000000000000000000000000000000000..f5658b7b8e7bc0be374b18ce85459f2f58c5bc6b --- /dev/null +++ b/codes/ebb29bbe/9945255.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + +} //end diff --git a/codes/ekdher/11188020.java b/codes/ekdher/11188020.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/ekdher/11188020.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ekwwu1/11122460.java b/codes/ekwwu1/11122460.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/ekwwu1/11122460.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/enRENE1/11005023.java b/codes/enRENE1/11005023.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/enRENE1/11005023.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/enkilee/15372338.java b/codes/enkilee/15372338.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/enkilee/15372338.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/enoughisenough/11364587.java b/codes/enoughisenough/11364587.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/enoughisenough/11364587.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/express77/15513152.java b/codes/express77/15513152.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/express77/15513152.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/ezh3wx95/11002373.java b/codes/ezh3wx95/11002373.java new file mode 100644 index 0000000000000000000000000000000000000000..823354248ac46c3e3650f1c6dd3e0d62c7ad26cd --- /dev/null +++ b/codes/ezh3wx95/11002373.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/f13306939842/.keep b/codes/f13306939842/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/f13306939842/10968297.java b/codes/f13306939842/10968297.java new file mode 100644 index 0000000000000000000000000000000000000000..c5585035958ffe8f04cc6f835f294ea420c7c2aa --- /dev/null +++ b/codes/f13306939842/10968297.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { +for (int i=0 ; ia[j+1]) { +int temp=a[j]; +a[j]=a[j+1]; +a[j+1]=temp; +} +} +} +} \ No newline at end of file diff --git a/codes/f18967940562/.keep b/codes/f18967940562/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/f18967940562/10972030.java b/codes/f18967940562/10972030.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/f18967940562/10972030.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/f370857894/.keep b/codes/f370857894/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/f370857894/10970517.java b/codes/f370857894/10970517.java new file mode 100644 index 0000000000000000000000000000000000000000..d5f586ad1c2f298d47266c7736708d19746c491a --- /dev/null +++ b/codes/f370857894/10970517.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] b, int n) { + for (int i=0 ; ib[j+1]) { + int temp=b[j]; + b[j]=b[j+1]; + b[j+1]=temp; + } + } + } +} diff --git a/codes/f435wedt/.keep b/codes/f435wedt/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/f435wedt/15743453.java b/codes/f435wedt/15743453.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/f435wedt/15743453.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/f456af67654/.keep b/codes/f456af67654/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/f456af67654/15743470.java b/codes/f456af67654/15743470.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/f456af67654/15743470.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/f734tasaf/.keep b/codes/f734tasaf/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/f734tasaf/15743456.java b/codes/f734tasaf/15743456.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/f734tasaf/15743456.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/fanghua/.keep b/codes/fanghua/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fanghua/10971642.java b/codes/fanghua/10971642.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/fanghua/10971642.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/fangqb/.keep b/codes/fangqb/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fangqb/10043498.java b/codes/fangqb/10043498.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/fangqb/10043498.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/fangying1/.keep b/codes/fangying1/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fangying1/10968297.java b/codes/fangying1/10968297.java new file mode 100644 index 0000000000000000000000000000000000000000..1752b8cbc3fdd044b5ce59517f8f6e5b3348a88b --- /dev/null +++ b/codes/fangying1/10968297.java @@ -0,0 +1,11 @@ +public static void sortFunc(int [] a, int n) { +for (int i=0 ; ia[j+1]) { +int temp=a[j]; +a[j]=a[j+1]; +a[j+1]=temp; +} +} +} +} \ No newline at end of file diff --git a/codes/fasfsa2412/.keep b/codes/fasfsa2412/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fasfsa2412/15743474.java b/codes/fasfsa2412/15743474.java new file mode 100644 index 0000000000000000000000000000000000000000..96508c1385b4a62859a2adea3c8dfae39051b7cd --- /dev/null +++ b/codes/fasfsa2412/15743474.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/fasfsaf292/.keep b/codes/fasfsaf292/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fasfsaf292/15743418.java b/codes/fasfsaf292/15743418.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/fasfsaf292/15743418.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/fasioc924/.keep b/codes/fasioc924/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fasioc924/15743426.java b/codes/fasioc924/15743426.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/fasioc924/15743426.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/fasttiger/10143432.java b/codes/fasttiger/10143432.java new file mode 100644 index 0000000000000000000000000000000000000000..93912216960266eb51f494e2a74a748085a12c4e --- /dev/null +++ b/codes/fasttiger/10143432.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + if(a != null && a.length > 0){ + int l = a.length; + if(l > n){ + l = n; + } + for (int i = 0; i< l; i++){ + for (int j=0; j a[j+1]){ + int t = a[j]; + a[j] = a[j+1]; + a[j+1] = t; + } + } + } + } +} //end \ No newline at end of file diff --git a/codes/fcc321/15630159.java b/codes/fcc321/15630159.java new file mode 100644 index 0000000000000000000000000000000000000000..d7fbec1bd5b39dee2d383d4d20f8690284d526d4 --- /dev/null +++ b/codes/fcc321/15630159.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 对数组进行冒泡排序,将无序数组变为有序数组 + * @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 - 1 - i; j++) { // 内层循环,从前往后依次比较相邻的两个元素 + if (a[j] > a[j + 1]) { // 如果前一个元素比后一个元素大,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/feipao/11252573.java b/codes/feipao/11252573.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/feipao/11252573.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/feiya123/15719128.java b/codes/feiya123/15719128.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/feiya123/15719128.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/fendou/15635967.java b/codes/fendou/15635967.java new file mode 100644 index 0000000000000000000000000000000000000000..fa7b3ff5555a00872225a421a281b11b145052d2 --- /dev/null +++ b/codes/fendou/15635967.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 将无序数组 a 按照从小到大的顺序进行排序 + * @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 diff --git a/codes/fengshang/15510907.java b/codes/fengshang/15510907.java new file mode 100644 index 0000000000000000000000000000000000000000..c1da30053b9b0e7d4b084859edaf1c76a325fe66 --- /dev/null +++ b/codes/fengshang/15510907.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 通过不断比较相邻元素,将较大的元素交换到数组的末尾,经过n-1轮比较后,数组变得有序。 + * @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 diff --git a/codes/fengshang/fengshang/15510907.java b/codes/fengshang/fengshang/15510907.java new file mode 100644 index 0000000000000000000000000000000000000000..01fb16399d83d1c2a0e52c988214b4ea75463c6b --- /dev/null +++ b/codes/fengshang/fengshang/15510907.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 通过不断比较相邻元素,将较大的元素交换到数组的末尾,经过n-1轮比较后,数组变得有序。 + * @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 diff --git a/codes/fengyeorz/15629835.java b/codes/fengyeorz/15629835.java new file mode 100644 index 0000000000000000000000000000000000000000..fdf32e5cfc95a9f290221769990e4791c334e55f --- /dev/null +++ b/codes/fengyeorz/15629835.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * 该函数实现了冒泡排序算法,将数组a中的元素按升序排列 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + // 遍历所有数组元素 + for (int i = 0; i < n - 1; i++) { + // 标记变量,用于检查是否发生了交换 + boolean swapped = false; + 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; + swapped = true; + } + } + // 如果内层循环没有发生交换,说明数组已经有序,可以提前退出 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/fengyu176/15759028.java b/codes/fengyu176/15759028.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b711a46fe664a20752955f5730ee67702ccb8b --- /dev/null +++ b/codes/fengyu176/15759028.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int huat = 0; huat < n - i - 1; huat++) { + if(a[huat] > a[huat + 1]) { + int temp = a[huat]; + a [huat] = a[huat + 1]; + a[huat + 1] = temp; + } + } + } + + +} //end,huat diff --git a/codes/fhbb111/15605446.java b/codes/fhbb111/15605446.java new file mode 100644 index 0000000000000000000000000000000000000000..04625a494ce3da760397a3c3c648cdbe5d0bfa71 --- /dev/null +++ b/codes/fhbb111/15605446.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end + diff --git a/codes/fhkjhkl876/.keep b/codes/fhkjhkl876/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fhkjhkl876/15743332.java b/codes/fhkjhkl876/15743332.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/fhkjhkl876/15743332.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/fhl3yue/15692389.java b/codes/fhl3yue/15692389.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/fhl3yue/15692389.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/fhvz199/15759040.java b/codes/fhvz199/15759040.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/fhvz199/15759040.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/flutter/11187840.java b/codes/flutter/11187840.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/flutter/11187840.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/fofone/15772455.java b/codes/fofone/15772455.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/fofone/15772455.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/fosmos/10385999.java b/codes/fosmos/10385999.java new file mode 100644 index 0000000000000000000000000000000000000000..dcb3be9513f62812667c57af8e4c4304b5262734 --- /dev/null +++ b/codes/fosmos/10385999.java @@ -0,0 +1,12 @@ +public static void bubbleSort( int[] a, int n ) { + for (int i = 0;i < a.length ;i++) { + for(int j = (i+1); j < a.length ;j++) { + int tep = 0; + if (a[i] > a[j]) { + tep = a[i]; + a[i] = a[j]; + a[j] = tep; + } + } + } +} \ No newline at end of file diff --git a/codes/fq18552765314/.keep b/codes/fq18552765314/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fq18552765314/10972612.java b/codes/fq18552765314/10972612.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/fq18552765314/10972612.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/franki_lxsq/9958657.java b/codes/franki_lxsq/9958657.java new file mode 100644 index 0000000000000000000000000000000000000000..e13c76bcf4cb1ee7db2f171ec3fa540a879af839 --- /dev/null +++ b/codes/franki_lxsq/9958657.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end diff --git a/codes/freeliujian/11351490.java b/codes/freeliujian/11351490.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/freeliujian/11351490.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/friklogff/15528029.java b/codes/friklogff/15528029.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/friklogff/15528029.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/fsa722/.keep b/codes/fsa722/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fsa722/15742665.java b/codes/fsa722/15742665.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/fsa722/15742665.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/fsafacc232/.keep b/codes/fsafacc232/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fsafacc232/15743001.java b/codes/fsafacc232/15743001.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/fsafacc232/15743001.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/fsdf435sdf/.keep b/codes/fsdf435sdf/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fsdf435sdf/15743405.java b/codes/fsdf435sdf/15743405.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/fsdf435sdf/15743405.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/fubing3/.keep b/codes/fubing3/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fubing3/9619048.java b/codes/fubing3/9619048.java new file mode 100644 index 0000000000000000000000000000000000000000..1752b8cbc3fdd044b5ce59517f8f6e5b3348a88b --- /dev/null +++ b/codes/fubing3/9619048.java @@ -0,0 +1,11 @@ +public static void sortFunc(int [] a, int n) { +for (int i=0 ; ia[j+1]) { +int temp=a[j]; +a[j]=a[j+1]; +a[j+1]=temp; +} +} +} +} \ No newline at end of file diff --git a/codes/fuzhong/10967384.java b/codes/fuzhong/10967384.java new file mode 100644 index 0000000000000000000000000000000000000000..c7db0a12c82390b8c8392060c67151185aa5fe32 --- /dev/null +++ b/codes/fuzhong/10967384.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * @param arr 待排序的数组 + * @param size 待排序的数组长度 + */ +public static void bubbleSort(int [] arr, int size){ + // 你的代码,使无序数组 arr 变得有序 + for(int i = 0 ; i < size - 1 ; i++){ + for(int j = 0 ; j < size - 1 - i ; j++){ + if(arr[j] > arr[j + 1]){ + int tmp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = tmp; + } + } + } + +} //end + diff --git a/codes/fx18902464802/.keep b/codes/fx18902464802/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fx18902464802/10971972.java b/codes/fx18902464802/10971972.java new file mode 100644 index 0000000000000000000000000000000000000000..ff66d8b5fb2b7962684d69645737e6ed11560524 --- /dev/null +++ b/codes/fx18902464802/10971972.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[y+1]) { + int temp=a[y]; + a[y]=a[y+1]; + a[y+1]=temp; + } + } + } +} diff --git a/codes/fy13073414213/.keep b/codes/fy13073414213/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fy13073414213/10972162.java b/codes/fy13073414213/10972162.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/fy13073414213/10972162.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/fyt345sdfgsd/.keep b/codes/fyt345sdfgsd/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/fyt345sdfgsd/15743397.java b/codes/fyt345sdfgsd/15743397.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/fyt345sdfgsd/15743397.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/gaoxinjmj/.keep b/codes/gaoxinjmj/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/gaoxinjmj/15759215.java b/codes/gaoxinjmj/15759215.java new file mode 100644 index 0000000000000000000000000000000000000000..d40803fb8fd6db6216a346341ff5180f0b773922 --- /dev/null +++ b/codes/gaoxinjmj/15759215.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/gedeshidai/15539757.java b/codes/gedeshidai/15539757.java new file mode 100644 index 0000000000000000000000000000000000000000..c7d4bd3a4f7751ebee0c866e0a6b4cc18ddef31d --- /dev/null +++ b/codes/gedeshidai/15539757.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 该函数通过冒泡排序算法对待排序的数组进行排序 + * @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 diff --git a/codes/gflu777/15508845.java b/codes/gflu777/15508845.java new file mode 100644 index 0000000000000000000000000000000000000000..7cd30ca2d60722a569bba6c83f6349fb70261177 --- /dev/null +++ b/codes/gflu777/15508845.java @@ -0,0 +1,19 @@ + /** + * 冒泡排序函数 + * 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-i-1; j++) { + if (a[j] > a[j+1]) { + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + } + } + } + + } //end diff --git a/codes/ghdfg3452/.keep b/codes/ghdfg3452/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/ghdfg3452/15743429.java b/codes/ghdfg3452/15743429.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/ghdfg3452/15743429.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/gin-lsl/11448781.java b/codes/gin-lsl/11448781.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/gin-lsl/11448781.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/giooter/.keep b/codes/giooter/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/giooter/15773918.java b/codes/giooter/15773918.java new file mode 100644 index 0000000000000000000000000000000000000000..9f86eb587f5fb5dee2fac7e589a1cf95128af5cc --- /dev/null +++ b/codes/giooter/15773918.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/gobuster/15555259.java b/codes/gobuster/15555259.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/gobuster/15555259.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/godawang/.keep b/codes/godawang/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/godawang/15764594.java b/codes/godawang/15764594.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/godawang/15764594.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/guagua123/15620667.java b/codes/guagua123/15620667.java new file mode 100644 index 0000000000000000000000000000000000000000..cee67cf6229d1a199df63ed1122d20749ba33784 --- /dev/null +++ b/codes/guagua123/15620667.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 对数组a进行升序排序 + * @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 diff --git a/codes/guanj123/15699820.java b/codes/guanj123/15699820.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/guanj123/15699820.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/gugulogs/15521175.java b/codes/gugulogs/15521175.java new file mode 100644 index 0000000000000000000000000000000000000000..f9340dccd37ede06d69d56d90660684be24f9b90 --- /dev/null +++ b/codes/gugulogs/15521175.java @@ -0,0 +1,13 @@ +public static void bubbleSort(int [] a, int n){ + 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; + } + } + } + +} //end + diff --git a/codes/gui8989/11228793.java b/codes/gui8989/11228793.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/gui8989/11228793.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/gujian3724/15541800.java b/codes/gujian3724/15541800.java new file mode 100644 index 0000000000000000000000000000000000000000..c2157ca539b033e4736d5a6d1745f3f74bdc4b51 --- /dev/null +++ b/codes/gujian3724/15541800.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 将无序数组通过冒泡排序变得有序 + * @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 diff --git a/codes/guoguoya/15742850.java b/codes/guoguoya/15742850.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/guoguoya/15742850.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/gwya123/15699461.java b/codes/gwya123/15699461.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/gwya123/15699461.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/h295276/15685251.java b/codes/h295276/15685251.java new file mode 100644 index 0000000000000000000000000000000000000000..584706c9dc0b96b832073b89ac9276cb3a135390 --- /dev/null +++ b/codes/h295276/15685251.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 使用冒泡排序算法对数组进行升序排序 + * @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 diff --git a/codes/h891539721/15718815.java b/codes/h891539721/15718815.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b4bb4b640425b88e8a8884aab8398c2374b077 --- /dev/null +++ b/codes/h891539721/15718815.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 将无序数组通过冒泡排序算法变为有序数组 + * @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 diff --git a/codes/haha176/15759089.java b/codes/haha176/15759089.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/haha176/15759089.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/hahane/15772179.java b/codes/hahane/15772179.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/hahane/15772179.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/handleRich/11471812.java b/codes/handleRich/11471812.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/handleRich/11471812.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/haoranx98/.keep b/codes/haoranx98/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/haoranx98/10039365.java b/codes/haoranx98/10039365.java new file mode 100644 index 0000000000000000000000000000000000000000..bd946e56245f533d12d032156931f19b418c55a5 --- /dev/null +++ b/codes/haoranx98/10039365.java @@ -0,0 +1,17 @@ + /* 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +} //end \ No newline at end of file diff --git a/codes/happymo/11212155.java b/codes/happymo/11212155.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/happymo/11212155.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/heiopx/11121859.java b/codes/heiopx/11121859.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/heiopx/11121859.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/helloY_Y/15644488.java b/codes/helloY_Y/15644488.java new file mode 100644 index 0000000000000000000000000000000000000000..a644c1f63a52c77f1b4e9e66c5d629157ab6d7a0 --- /dev/null +++ b/codes/helloY_Y/15644488.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end + diff --git a/codes/heshu1/15640537.java b/codes/heshu1/15640537.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/heshu1/15640537.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/hh456123/15721443.java b/codes/hh456123/15721443.java new file mode 100644 index 0000000000000000000000000000000000000000..824031d9473ef3c11d89a1c1419f02422ae423fe --- /dev/null +++ b/codes/hh456123/15721443.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 通过重复地遍历要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 + * 遍历数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。 + * @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 - 1 - i; j++) { // 内层循环控制每趟排序多少次 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/hhj123/15639946.java b/codes/hhj123/15639946.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/hhj123/15639946.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/hlsscoder/15606370.java b/codes/hlsscoder/15606370.java new file mode 100644 index 0000000000000000000000000000000000000000..9de98c3feda56594aba5c4720c49ec34b7158aa0 --- /dev/null +++ b/codes/hlsscoder/15606370.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 对数组进行冒泡排序,使其变得有序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/hly123/.keep b/codes/hly123/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/hly123/10984210.java b/codes/hly123/10984210.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/hly123/10984210.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/hly252984658/.keep b/codes/hly252984658/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/hly252984658/10979977.java b/codes/hly252984658/10979977.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/hly252984658/10979977.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/hnn111/15577556.java b/codes/hnn111/15577556.java new file mode 100644 index 0000000000000000000000000000000000000000..25b3bbe48bce467063cee5629079bc6a1504a0ec --- /dev/null +++ b/codes/hnn111/15577556.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end diff --git a/codes/hongshen/.keep b/codes/hongshen/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/hongshen/10039145.java b/codes/hongshen/10039145.java new file mode 100644 index 0000000000000000000000000000000000000000..64e1f42376f0de61f9abfeab40d9746c5e337561 --- /dev/null +++ b/codes/hongshen/10039145.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 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+1]; + a[j+1] = a[j]; + a[j] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/hongyaya/15683533.java b/codes/hongyaya/15683533.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/hongyaya/15683533.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/hopekai/15586507.java b/codes/hopekai/15586507.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/hopekai/15586507.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/hua0x522/10375834.java b/codes/hua0x522/10375834.java new file mode 100644 index 0000000000000000000000000000000000000000..f04a8c13091802663ec364ff5aff01be6a4f33f9 --- /dev/null +++ b/codes/hua0x522/10375834.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (j < n-1 && a[j] > a[j+1]) { + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/huaano/15772611.java b/codes/huaano/15772611.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/huaano/15772611.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/hualine/15772389.java b/codes/hualine/15772389.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/hualine/15772389.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/huang856/.keep b/codes/huang856/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/huang856/10982875.java b/codes/huang856/10982875.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/huang856/10982875.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/huangduoyan2024/.I94UY3.java.swp b/codes/huangduoyan2024/.I94UY3.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..95d65cb9d367ae30eaa2cf42eaa8960a6eedfe9e Binary files /dev/null and b/codes/huangduoyan2024/.I94UY3.java.swp differ diff --git a/codes/huangduoyan2024/15343275.java b/codes/huangduoyan2024/15343275.java new file mode 100644 index 0000000000000000000000000000000000000000..33f047c9c105c273675449f1bd2f3d9631fb127f --- /dev/null +++ b/codes/huangduoyan2024/15343275.java @@ -0,0 +1,12 @@ +public static void bubbleSort(int a[], int n) +{ + for (int i = 0; i < n - 1; i++) { + for (int j = n - 1; j > i; j--) { + if (a[j] < a[j - 1]) { + int t = a[j]; + a[j] = a[j - 1]; + a[j - 1] = t; + } + } + } +} diff --git a/codes/huangxiaoyan/10971566.java b/codes/huangxiaoyan/10971566.java new file mode 100644 index 0000000000000000000000000000000000000000..deb2438785c696d09e985c35997c2f2bc5445a90 --- /dev/null +++ b/codes/huangxiaoyan/10971566.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/huanjiyan/15607160.java b/codes/huanjiyan/15607160.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/huanjiyan/15607160.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/huankuai/.java b/codes/huankuai/.java new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/huankuai/9962039.java b/codes/huankuai/9962039.java new file mode 100644 index 0000000000000000000000000000000000000000..82b73c8ff8181a822b4e5b9b4a74866761c7b1ca --- /dev/null +++ b/codes/huankuai/9962039.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end + diff --git a/codes/huliangsheng/.keep b/codes/huliangsheng/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/huliangsheng/15759181.java b/codes/huliangsheng/15759181.java new file mode 100644 index 0000000000000000000000000000000000000000..d40803fb8fd6db6216a346341ff5180f0b773922 --- /dev/null +++ b/codes/huliangsheng/15759181.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/huqi88/15222808.java b/codes/huqi88/15222808.java new file mode 100644 index 0000000000000000000000000000000000000000..ce2dfba6b2a040d5c8796bd2c0f8a388ff9bda17 --- /dev/null +++ b/codes/huqi88/15222808.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int[] a, int n) { + if (n <= 1) { + return; // 如果数组长度为0或1,则不需要排序 + } + + 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; + } + } + } + } diff --git a/codes/hzhong/15527208.java b/codes/hzhong/15527208.java new file mode 100644 index 0000000000000000000000000000000000000000..a8d0ec5ad76b46db6e86535784ca44b6ebaee312 --- /dev/null +++ b/codes/hzhong/15527208.java @@ -0,0 +1,18 @@ +/** * 冒泡排序函数 + * * 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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换a[j]和a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +}// end + diff --git a/codes/idealismer/15406184.java b/codes/idealismer/15406184.java new file mode 100644 index 0000000000000000000000000000000000000000..eb3d65ef3753e77c86eaf6602b03ae2cd9c2a61e --- /dev/null +++ b/codes/idealismer/15406184.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * 通过比较相邻元素并交换它们(如果需要),将数组a排序为升序。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 创建一个标志位,用于检测数组是否已排序 + boolean swapped = false; + 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; + // 交换后,标志位设为true + swapped = true; + } + } + // 如果内层循环没有交换任何元素,说明数组已排序完成 + if (!swapped) { + break; + } + } +} // end bubbleSort diff --git a/codes/ignoreme/11207270.java b/codes/ignoreme/11207270.java new file mode 100644 index 0000000000000000000000000000000000000000..191de91d18bdb330ab1609aaa3b20eeb19226481 --- /dev/null +++ b/codes/ignoreme/11207270.java @@ -0,0 +1,11 @@ + public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < a.length - 1; i++) { + for (int j = 0; j < a.length - 1 - i; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j + 1]; + a[j + 1] = a[j]; + a[j] = temp; + } + } + } + } \ No newline at end of file diff --git a/codes/ikzsm77/15613401.java b/codes/ikzsm77/15613401.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/ikzsm77/15613401.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/ilove360/9937750.java b/codes/ilove360/9937750.java new file mode 100644 index 0000000000000000000000000000000000000000..9061f1f369a9b7ec1ce898807e9db19750b18c46 --- /dev/null +++ b/codes/ilove360/9937750.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp = 0 ; + for(int i = 0 ;i< n -1; i++){ + for(int j = 0; ja[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + + } + System.out.println("a排序后:"); + + for(int i = 0; i a[j+1]) { + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} //end diff --git a/codes/interceptors/11148333.java b/codes/interceptors/11148333.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/interceptors/11148333.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/ivan886/15517024.java b/codes/ivan886/15517024.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/ivan886/15517024.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/jacksonstack/15157304.java b/codes/jacksonstack/15157304.java new file mode 100644 index 0000000000000000000000000000000000000000..fd232d5643a65df16fc2710915a3ad1032974220 --- /dev/null +++ b/codes/jacksonstack/15157304.java @@ -0,0 +1,32 @@ + /** + * 冒泡排序函数 + * more: + * 1. 从上一次交换索引位置开始;部分有序 + * 2. 后续已经有序,退出比较 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] a, int n){ + int last = 0; // 最后一次交换的索引 + int outIndex = n - 1; + int innerIndex = n - 1; + for (int i = 0; i < outIndex; i++) { + // 是否发生交换, 发生 仍未有序; 未发生 已有序 + boolean flag = false; + if (last != 0) { + innerIndex = last; + } + for (int j = 0; j < innerIndex; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + flag = true; + last = j; + } + } + if (!flag) { + break; + } + } + } diff --git a/codes/java0111/15636073.java b/codes/java0111/15636073.java new file mode 100644 index 0000000000000000000000000000000000000000..855496ea92540342d41f4a245d439472243073cb --- /dev/null +++ b/codes/java0111/15636073.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = n - 1; i > 0; i--){ + for(int j = 0; j < i; j++){ + if(a[j] > a[j + 1]){ + int tem = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tem; + } + } + } + +} //end diff --git a/codes/jayjay/9955470.java b/codes/jayjay/9955470.java new file mode 100644 index 0000000000000000000000000000000000000000..82b73c8ff8181a822b4e5b9b4a74866761c7b1ca --- /dev/null +++ b/codes/jayjay/9955470.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end + diff --git a/codes/jbace2/.keep b/codes/jbace2/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/jbace2/10041152.java b/codes/jbace2/10041152.java new file mode 100644 index 0000000000000000000000000000000000000000..29d27043d3c8103739e7a1d2a27e77b4cc475876 --- /dev/null +++ b/codes/jbace2/10041152.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 diff --git a/codes/jerrywang/.keep b/codes/jerrywang/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/jerrywang/10972482.java b/codes/jerrywang/10972482.java new file mode 100644 index 0000000000000000000000000000000000000000..862a031b6f73aac6e6e6656df710e9caa439d4c0 --- /dev/null +++ b/codes/jerrywang/10972482.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int m=0 ; ma[q+1]) { + int temp=a[q]; + a[q]=a[q+1]; + a[q+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/jerrywang/10972482.java] b/codes/jerrywang/10972482.java] new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/jerrywang1982/15623035.java b/codes/jerrywang1982/15623035.java new file mode 100644 index 0000000000000000000000000000000000000000..c4ea11374b4d2d0fb45b5ea9e552f59e37a38201 --- /dev/null +++ b/codes/jerrywang1982/15623035.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 使用冒泡排序算法对数组进行升序排序 + * @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]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/jgjfvj767/.keep b/codes/jgjfvj767/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/jgjfvj767/15743251.java b/codes/jgjfvj767/15743251.java new file mode 100644 index 0000000000000000000000000000000000000000..96508c1385b4a62859a2adea3c8dfae39051b7cd --- /dev/null +++ b/codes/jgjfvj767/15743251.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/jianghao/15366705.java b/codes/jianghao/15366705.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/jianghao/15366705.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/jichen/12429463.java b/codes/jichen/12429463.java new file mode 100644 index 0000000000000000000000000000000000000000..d2207f8580de8965b35821678898ea8c7ae03ab5 --- /dev/null +++ b/codes/jichen/12429463.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 0; j < n - i - 1; ++j) { + if(a[j] > a[j + 1]) { + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end diff --git a/codes/jideliy89mxp/10942446.java b/codes/jideliy89mxp/10942446.java new file mode 100644 index 0000000000000000000000000000000000000000..c05a772d83b85c60bdcae220bf3d2ed176d8e54c --- /dev/null +++ b/codes/jideliy89mxp/10942446.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp; + for (int i = 0; i < n - 1; i++) { + int count = 0; + for (int j = 0; j < n - 1 - i; j++) { + if (a[j] > a[j + 1]) { + temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + count++; + } + } + if (count == 0) { + break; + } + } +} //end diff --git a/codes/jingge15116238811/10969429.java b/codes/jingge15116238811/10969429.java new file mode 100644 index 0000000000000000000000000000000000000000..deb2438785c696d09e985c35997c2f2bc5445a90 --- /dev/null +++ b/codes/jingge15116238811/10969429.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/jingqing3948/15533535.java b/codes/jingqing3948/15533535.java new file mode 100644 index 0000000000000000000000000000000000000000..441eb8963da90b392fc88143884bb8bea1bc72ac --- /dev/null +++ b/codes/jingqing3948/15533535.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i,j; + for(i=0;ia[j+1]){ + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } + + +} //end diff --git a/codes/jinjin1234567/15628228.java b/codes/jinjin1234567/15628228.java new file mode 100644 index 0000000000000000000000000000000000000000..eb29d98eb24bfc163352191a8009f3fd17064de2 --- /dev/null +++ b/codes/jinjin1234567/15628228.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 依次比较相邻的元素,如果顺序错误就交换它们,遍历数组的工作是重复地进行直到没有再需要交换,也就是说该数组已经排序完成。 + * @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 - 1 - i; j++) { // 内层循环控制每趟比较的次数 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/jinxin177/15759096.java b/codes/jinxin177/15759096.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/jinxin177/15759096.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/jinya123/15684545.java b/codes/jinya123/15684545.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/jinya123/15684545.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/jiucai131/11476990.java b/codes/jiucai131/11476990.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/jiucai131/11476990.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/jiujiu/15555981.java b/codes/jiujiu/15555981.java new file mode 100644 index 0000000000000000000000000000000000000000..ccf5e94f6a37103e978629635e2244c0aa664f0e --- /dev/null +++ b/codes/jiujiu/15555981.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 将无序数组通过冒泡排序算法变得有序 + * @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; + } + } + } + // 数组a现在已经变得有序 +} //end diff --git a/codes/jiujiuhaizi/.keep b/codes/jiujiuhaizi/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/jiujiuhaizi/10972159.java b/codes/jiujiuhaizi/10972159.java new file mode 100644 index 0000000000000000000000000000000000000000..4879af620f6837399326a7c38fab9ec28e177ad6 --- /dev/null +++ b/codes/jiujiuhaizi/10972159.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + n=a[j]; + a[j]=a[j+1]; + a[j+1]=n; + } + } + } + for(int i=0;i a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/jkgao007/10515263.java b/codes/jkgao007/10515263.java new file mode 100644 index 0000000000000000000000000000000000000000..e712e076ad44564097e182dc460ddc5a9ccad945 --- /dev/null +++ b/codes/jkgao007/10515263.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 diff --git a/codes/jkxllj/15631418.java b/codes/jkxllj/15631418.java new file mode 100644 index 0000000000000000000000000000000000000000..d24a24b804f48d74cbe4f2ea3b9ff381b7fb476d --- /dev/null +++ b/codes/jkxllj/15631418.java @@ -0,0 +1,19 @@ + +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0;ia[j+1]){ + int temp=a[j+1]; + a[j+1]=a[j]; + a[j]=temp; + } + } + } +} //end diff --git a/codes/jmdajiang/.keep b/codes/jmdajiang/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/jmdajiang/15764743.java b/codes/jmdajiang/15764743.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/jmdajiang/15764743.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/jokemanfire/11650604.java b/codes/jokemanfire/11650604.java new file mode 100644 index 0000000000000000000000000000000000000000..62d1c299a5756f3dedf258cb9ec3e5ca352c73d9 --- /dev/null +++ b/codes/jokemanfire/11650604.java @@ -0,0 +1,13 @@ +public static void bubbleSort(int []a,int n) +{ + for(int i = 0 ;i< a.length -1; i++){ + for(int j = 0; ja[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + + } +} diff --git a/codes/juking/10340196.java b/codes/juking/10340196.java new file mode 100644 index 0000000000000000000000000000000000000000..2427354dd0779383a567a842590db45bece9e707 --- /dev/null +++ b/codes/juking/10340196.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] array, int n){ + // 你的代码,使无序数组 array 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < n - 1; j++) { + if (array[j] > array[j + 1]) { + // Swap the elements + int temp = array[j]; + array[j] = array[j + 1]; + array[j + 1] = temp; + } + } + } +} diff --git a/codes/k8scat/11864664.java b/codes/k8scat/11864664.java new file mode 100644 index 0000000000000000000000000000000000000000..43bde320f7dbaab334959abe6c825e0a8acc65ea --- /dev/null +++ b/codes/k8scat/11864664.java @@ -0,0 +1,12 @@ +public static void bubbleSort(int[] arr, int n) { + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - i - 1; j++) { + if (arr[j] > arr[j + 1]) { + // 交换arr[j]和arr[j+1] + int temp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = temp; + } + } + } +} diff --git a/codes/kaiSYJ/15488956.java b/codes/kaiSYJ/15488956.java new file mode 100644 index 0000000000000000000000000000000000000000..cc79a00958d5e633e4c62561a6d0bb958dc799b2 --- /dev/null +++ b/codes/kaiSYJ/15488956.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * 通过比较相邻的元素来工作,如果它们的顺序错误就把它们交换过来。 + * 遍历数组的工作是重复地进行直到没有再需要交换,也就是说该数组已经排序完成。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 标记变量,用于检测在一次遍历中是否发生了交换 + boolean swapped = false; + 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; + // 标记发生了交换 + swapped = true; + } + } + // 如果在一次遍历中没有发生交换,说明数组已经有序,可以提前结束 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/kaiSYJ/15589878.java b/codes/kaiSYJ/15589878.java new file mode 100644 index 0000000000000000000000000000000000000000..1e66d7f4d6dd0480ff1b73795b5f74b9af709b25 --- /dev/null +++ b/codes/kaiSYJ/15589878.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 功能:对数组进行冒泡排序 + * @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 - 1 - i; j++) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/kangwang/11615067.java b/codes/kangwang/11615067.java new file mode 100644 index 0000000000000000000000000000000000000000..7dd5e4769cf7ffa2ae36546da889e54187312713 --- /dev/null +++ b/codes/kangwang/11615067.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int temp = a[i]; + a[i] = a[j]; + a[j] = temp; + } + } + } + + +} //end diff --git a/codes/kankanya/15772087.java b/codes/kankanya/15772087.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/kankanya/15772087.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/katooo/11209021.java b/codes/katooo/11209021.java new file mode 100644 index 0000000000000000000000000000000000000000..c1ef133df1bd65a38efa4e1904729f02711c025d --- /dev/null +++ b/codes/katooo/11209021.java @@ -0,0 +1,19 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end + diff --git a/codes/kira11535/15774608.java b/codes/kira11535/15774608.java new file mode 100644 index 0000000000000000000000000000000000000000..c10daff194011cca5d72605f5149c9f38e8f0db2 --- /dev/null +++ b/codes/kira11535/15774608.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 这是一个简单的排序算法,通过重复地遍历要排序的数列,一次比较两个元素, + * 如果他们的顺序错误就把他们交换过来。遍历数列的工作是重复地进行直到没有再需要交换, + * 也就是说该数列已经排序完成。 + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j + 1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/kkya123/15722815.java b/codes/kkya123/15722815.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/kkya123/15722815.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/kongshang/15699583.java b/codes/kongshang/15699583.java new file mode 100644 index 0000000000000000000000000000000000000000..94a5caabef6912faacfee5874eb5026ea2c5aeba --- /dev/null +++ b/codes/kongshang/15699583.java @@ -0,0 +1,31 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + // 标记变量,用于优化冒泡排序,如果一趟排序中没有发生交换,则说明数组已经有序,可以提前结束排序 + boolean swapped; + // 外层循环控制遍历次数 + for (int i = 0; i < n - 1; i++) { + swapped = false; + // 内层循环负责进行相邻元素的比较和可能的交换 + 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; + // 标记发生了交换 + swapped = true; + } + } + // 如果在这次遍历中没有发生交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/kongshang/15699673.java b/codes/kongshang/15699673.java new file mode 100644 index 0000000000000000000000000000000000000000..b33a11ac1eea98e2c6527ce7e38674a3058b9bab --- /dev/null +++ b/codes/kongshang/15699673.java @@ -0,0 +1,32 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + // 标记变量,用于优化冒泡排序,如果一趟排序中没有发生交换,则说明数组已经有序,可以提前结束排序 + boolean swapped; + // 外层循环控制遍历次数 + for (int i = 0; i < n - 1; i++) { + swapped = false; + // 内层循环负责进行相邻元素的比较和可能的交换 + 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; + // 标记发生了交换 + swapped = true; + } + } + // 如果在这次遍历中没有发生交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end + diff --git a/codes/kongshang/15700235.java b/codes/kongshang/15700235.java new file mode 100644 index 0000000000000000000000000000000000000000..94a5caabef6912faacfee5874eb5026ea2c5aeba --- /dev/null +++ b/codes/kongshang/15700235.java @@ -0,0 +1,31 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + // 标记变量,用于优化冒泡排序,如果一趟排序中没有发生交换,则说明数组已经有序,可以提前结束排序 + boolean swapped; + // 外层循环控制遍历次数 + for (int i = 0; i < n - 1; i++) { + swapped = false; + // 内层循环负责进行相邻元素的比较和可能的交换 + 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; + // 标记发生了交换 + swapped = true; + } + } + // 如果在这次遍历中没有发生交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/kukuku123/.15650271.java.swp b/codes/kukuku123/.15650271.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..e4f0cdf5fb22bc307950f49b04a5fe256ad20642 Binary files /dev/null and b/codes/kukuku123/.15650271.java.swp differ diff --git a/codes/kukuku123/15650271.java b/codes/kukuku123/15650271.java new file mode 100644 index 0000000000000000000000000000000000000000..607b6ee313289736c360dc06dc6faee7bf0651ca --- /dev/null +++ b/codes/kukuku123/15650271.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * 对输入的整数数组a进行升序排序 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + if (a == null || n <= 0) { + return; + } + + // 外层循环控制遍历次数,最多需要遍历n-1轮 + 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; + } + } + } +} // end diff --git a/codes/kunzhi/.keep b/codes/kunzhi/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/kunzhi/15606505.java b/codes/kunzhi/15606505.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/kunzhi/15606505.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/kuqiu123/15585804.java b/codes/kuqiu123/15585804.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/kuqiu123/15585804.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/l1017026323/15630469.java b/codes/l1017026323/15630469.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/l1017026323/15630469.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/lailailai/11211174.java b/codes/lailailai/11211174.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/lailailai/11211174.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/lala12/15700256.java b/codes/lala12/15700256.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/lala12/15700256.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/lambdang/11472883.java b/codes/lambdang/11472883.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/lambdang/11472883.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/lan0bo/11297643.java b/codes/lan0bo/11297643.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/lan0bo/11297643.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/lanlan/11115524.java b/codes/lanlan/11115524.java new file mode 100644 index 0000000000000000000000000000000000000000..ba8c52af1a5f913937c5dc33ff58a9a3b1a0984d --- /dev/null +++ b/codes/lanlan/11115524.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 1; j < n - i; j++) { + if(a[j - 1] > a[j]) { + int temp = a[j - 1]; + a[j - 1] = a[j]; + a[j] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/lanlanya/15684957.java b/codes/lanlanya/15684957.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/lanlanya/15684957.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/laomocy/.keep b/codes/laomocy/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/laomocy/15768870.java b/codes/laomocy/15768870.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/laomocy/15768870.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/laoshifu/15520696.java b/codes/laoshifu/15520696.java new file mode 100644 index 0000000000000000000000000000000000000000..c82f33f1042c930bdacdd6a43a1d00d97b6ca8bd --- /dev/null +++ b/codes/laoshifu/15520696.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 通过不断比较相邻元素,将较大的元素交换到数组的末尾,经过n-1轮比较后,数组变得有序。 + * @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 \ No newline at end of file diff --git a/codes/last123/15721253.java b/codes/last123/15721253.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/last123/15721253.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/lbhusvkfj/15582699.java b/codes/lbhusvkfj/15582699.java new file mode 100644 index 0000000000000000000000000000000000000000..23d208a4b8fdb0880b8baebff2ba2d52ee013b81 --- /dev/null +++ b/codes/lbhusvkfj/15582699.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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]) { + // 交换a[j]和a[j+1]的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/leikaiya/15772650.java b/codes/leikaiya/15772650.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/leikaiya/15772650.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/leikaya/15772650.java b/codes/leikaya/15772650.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/leikaya/15772650.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/leitongjiang2/.keep b/codes/leitongjiang2/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/leitongjiang2/15757898 b/codes/leitongjiang2/15757898 new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/leitongjiang2/15757898 @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/leitongjiang2/15757898.java b/codes/leitongjiang2/15757898.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/leitongjiang2/15757898.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/leoaeon/15620248.java b/codes/leoaeon/15620248.java new file mode 100644 index 0000000000000000000000000000000000000000..796a4e920c85d8eacd29b63d90370fb7d6753e15 --- /dev/null +++ b/codes/leoaeon/15620248.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 + diff --git a/codes/lgy1584899472/15607389.java b/codes/lgy1584899472/15607389.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/lgy1584899472/15607389.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/lhcoder/15630391.java b/codes/lhcoder/15630391.java new file mode 100644 index 0000000000000000000000000000000000000000..9de98c3feda56594aba5c4720c49ec34b7158aa0 --- /dev/null +++ b/codes/lhcoder/15630391.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 对数组进行冒泡排序,使其变得有序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/lhtcn/.keep b/codes/lhtcn/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/lhtscavc/.keep b/codes/lhtscavc/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/lhtscavc/15710834.java b/codes/lhtscavc/15710834.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/lhtscavc/15710834.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/lhzs123/15684690.java b/codes/lhzs123/15684690.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/lhzs123/15684690.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/li781117/15518855.java b/codes/li781117/15518855.java new file mode 100644 index 0000000000000000000000000000000000000000..64e12936e937f20216f7c02c6716093d6a3c30d5 --- /dev/null +++ b/codes/li781117/15518855.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 对数组a进行冒泡排序,使其变为有序数组 + * @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 diff --git a/codes/liaojiji/15699956.java b/codes/liaojiji/15699956.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/liaojiji/15699956.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/lideshengdsb/15545860.java b/codes/lideshengdsb/15545860.java new file mode 100644 index 0000000000000000000000000000000000000000..2252b818e6125ed4f8bbd23eca03c12c15ca1757 --- /dev/null +++ b/codes/lideshengdsb/15545860.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/lidongshi/10229157.java b/codes/lidongshi/10229157.java new file mode 100644 index 0000000000000000000000000000000000000000..33f024280ec9e03701cc23cb42410308718b4ed9 --- /dev/null +++ b/codes/lidongshi/10229157.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 = i+1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[i]; + a[i] = a[j]; + a[j] = temp; + } + } + } +} //end diff --git a/codes/lihuizhe666/15774599.java b/codes/lihuizhe666/15774599.java new file mode 100644 index 0000000000000000000000000000000000000000..50396104a715f700f99cb68de3e259257dd1db83 --- /dev/null +++ b/codes/lihuizhe666/15774599.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 将数组a按照从小到大的顺序排序 + * @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 - 1 - i; j++) { // 内层循环负责相邻元素两两比较 + if (a[j] > a[j + 1]) { // 如果前一个元素比后一个元素大,则交换它们 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/linchong/9954468.java b/codes/linchong/9954468.java new file mode 100644 index 0000000000000000000000000000000000000000..10dbc6525b8c4427dda5055b3f3c224c68398d2c --- /dev/null +++ b/codes/linchong/9954468.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end diff --git a/codes/linliangdong/.keep b/codes/linliangdong/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/linliangdong/15764880.java b/codes/linliangdong/15764880.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/linliangdong/15764880.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/linling0421/.keep b/codes/linling0421/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/linling0421/10979563.java b/codes/linling0421/10979563.java new file mode 100644 index 0000000000000000000000000000000000000000..ecc6b910e01246737286675ada360c1f523475f8 --- /dev/null +++ b/codes/linling0421/10979563.java @@ -0,0 +1,12 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} + diff --git a/codes/liquor/11292981.java b/codes/liquor/11292981.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/liquor/11292981.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/lisonghao/15710966.java b/codes/lisonghao/15710966.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec373aee12c8b4795c0d670e772620e90ee630e --- /dev/null +++ b/codes/lisonghao/15710966.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/liuYanFen/15720723.java b/codes/liuYanFen/15720723.java new file mode 100644 index 0000000000000000000000000000000000000000..543adb5418beaf81825691196818a31f41517347 --- /dev/null +++ b/codes/liuYanFen/15720723.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 该函数使用冒泡排序算法对数组进行排序 + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换数组元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/liu_chen_yang/15629230.java b/codes/liu_chen_yang/15629230.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/liu_chen_yang/15629230.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/liugela/.keep b/codes/liugela/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/liugela/15756309.java b/codes/liugela/15756309.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/liugela/15756309.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/liuguangsen0409/15717549.java b/codes/liuguangsen0409/15717549.java new file mode 100644 index 0000000000000000000000000000000000000000..0b2f43927cdd5e8f9f9e916fd1e2ab5cbcc69f53 --- /dev/null +++ b/codes/liuguangsen0409/15717549.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 功能:对数组a进行升序排序 + * @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 diff --git a/codes/liujiayi/10517239.java b/codes/liujiayi/10517239.java new file mode 100644 index 0000000000000000000000000000000000000000..a66b179edfb3ce05000cf74958cf3d7d2793828e --- /dev/null +++ b/codes/liujiayi/10517239.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 1; j < n - i; j++) { + if(a[j - 1] > a[j]) { + int temp = a[j - 1]; + a[j - 1] = a[j]; + a[j] = temp; + } + } + } +} //end diff --git a/codes/liulink/15774650.java b/codes/liulink/15774650.java new file mode 100644 index 0000000000000000000000000000000000000000..bd0ba76337e821ab49d132d93947e1cbe6612c17 --- /dev/null +++ b/codes/liulink/15774650.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 将一个整数数组按照从小到大的顺序进行排序 + * @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 - 1 - i; j++) { + // 如果前一个元素比后一个元素大,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/liuyctt12/15630469.java b/codes/liuyctt12/15630469.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/liuyctt12/15630469.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/liuyiyi/15714289.java b/codes/liuyiyi/15714289.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/liuyiyi/15714289.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/liwei2496/11466656.java b/codes/liwei2496/11466656.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/liwei2496/11466656.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/lixiang1996/15516370.java b/codes/lixiang1996/15516370.java new file mode 100644 index 0000000000000000000000000000000000000000..de06d4bd1b80b0f522dcc6e320151ef767941bd8 --- /dev/null +++ b/codes/lixiang1996/15516370.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * @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]) { + // 交换 a[j] 和 a[j + 1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/liyanfen1/15607550.java b/codes/liyanfen1/15607550.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/liyanfen1/15607550.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/lj18263537279/.keep b/codes/lj18263537279/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/lj18263537279/10972375.java b/codes/lj18263537279/10972375.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/lj18263537279/10972375.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/ll13174074984/.keep b/codes/ll13174074984/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/ll13174074984/10972293.java b/codes/ll13174074984/10972293.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/ll13174074984/10972293.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/lmc666/15632201.java b/codes/lmc666/15632201.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/lmc666/15632201.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/lodyn123/15488861.java b/codes/lodyn123/15488861.java new file mode 100644 index 0000000000000000000000000000000000000000..f55efd315e5f3fd7e4cdbf3d11557610ec6333b5 --- /dev/null +++ b/codes/lodyn123/15488861.java @@ -0,0 +1,14 @@ + public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + 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 diff --git a/codes/lolitot/.keep b/codes/lolitot/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/lolitot/10040248.java b/codes/lolitot/10040248.java new file mode 100644 index 0000000000000000000000000000000000000000..29d27043d3c8103739e7a1d2a27e77b4cc475876 --- /dev/null +++ b/codes/lolitot/10040248.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 diff --git a/codes/long22/11031968.java b/codes/long22/11031968.java new file mode 100644 index 0000000000000000000000000000000000000000..4d3191cfa222c1b44ce622a958ebf742e1bf4958 --- /dev/null +++ b/codes/long22/11031968.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} diff --git a/codes/long93/15676797.java b/codes/long93/15676797.java new file mode 100644 index 0000000000000000000000000000000000000000..e19af71f108d7db632940367ec2223352b2c268c --- /dev/null +++ b/codes/long93/15676797.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * 通过重复遍历待排序的数组,比较相邻的元素并交换它们(如果它们在错误的顺序), + * 直到没有更多的交换需要,即该数组已经排序。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { // 外层循环控制排序的趟数 + boolean swapped = false; // 用于标记某一趟是否发生了交换 + 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; + swapped = true; // 标记发生了交换 + } + } + if (!swapped) { // 如果某一趟没有发生交换,说明数组已经有序,可以提前退出 + break; + } + } +} // end diff --git a/codes/loveer/15720497.java b/codes/loveer/15720497.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/loveer/15720497.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/lovewang/11307245.java b/codes/lovewang/11307245.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/lovewang/11307245.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/lovscene/11290992.java b/codes/lovscene/11290992.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/lovscene/11290992.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/lsmir2/13427738.java b/codes/lsmir2/13427738.java new file mode 100644 index 0000000000000000000000000000000000000000..9038393a2b67fc9b2569a8986b2b9b4b08804347 --- /dev/null +++ b/codes/lsmir2/13427738.java @@ -0,0 +1,41 @@ +/** + * 冒泡排序函数 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + if (n <= 1) { + return; + } + + /* 最后一次交换的位置 */ + int lastExchangeIndex = 0; + /* 无序数列的边界,每次只需要比较到这里即可退出循环 */ + int sortedBorder = n - 1; + + for (int i = 0; i < n; i++) { + /* 提前退出冒泡循环的标志位 */ + boolean swapped = false; + + for (int j = 0; j < sortedBorder; j++) { + if (a[j] > a[j + 1]) { + /* 交换元素 */ + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + + /* 更新最后一次交换的位置 */ + lastExchangeIndex = j; + swapped = true; + } + } + + /* 更新无序数列的边界 */ + sortedBorder = lastExchangeIndex; + + /* 如果一次循环中没有发生元素交换,说明已经排序完成,提前退出 */ + if (!swapped) { + break; + } + } +} diff --git a/codes/ltq0319/15757963.java b/codes/ltq0319/15757963.java new file mode 100644 index 0000000000000000000000000000000000000000..7ce620c3e5da73497f3bd1c48010bf1366a3fe53 --- /dev/null +++ b/codes/ltq0319/15757963.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * 将无序数组通过冒泡排序算法变为有序数组 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 设置一个标志位,用于优化算法,减少不必要的比较 + boolean swapped = false; + 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; + // 如果有元素交换,则标志位设为true + swapped = true; + } + } + // 如果没有元素交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end + + diff --git a/codes/luo111/15754678.java b/codes/luo111/15754678.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/luo111/15754678.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/luogege/15634607.java b/codes/luogege/15634607.java new file mode 100644 index 0000000000000000000000000000000000000000..d8a8b6b86bb96853f7c34e5655e91c18cbd91eb6 --- /dev/null +++ b/codes/luogege/15634607.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int luoluo = 0; luoluo < n - i - 1; luoluo++) { + if(a[luoluo] > a[luoluo + 1]) { + int temp = a[luoluo]; + a [luoluo] = a[luoluo + 1]; + a[luoluo + 1] = temp; + } + } + } + + +} //end,luoluo \ No newline at end of file diff --git a/codes/luoluo123/15634481.java b/codes/luoluo123/15634481.java new file mode 100644 index 0000000000000000000000000000000000000000..6d56cc245b65789ffc55510e1407e393e8fa8a7a --- /dev/null +++ b/codes/luoluo123/15634481.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int luoluo = 0; luoluo < n - i - 1; luoluo++) { + if(a[luoluo] > a[luoluo + 1]) { + int temp = a[luoluo]; + a [luoluo] = a[luoluo + 1]; + a[luoluo + 1] = temp; + } + } + } + + +} //end,luoluo diff --git a/codes/luowei/15609646.java b/codes/luowei/15609646.java new file mode 100644 index 0000000000000000000000000000000000000000..43375d79244ec8f0010facb911b0ecb805e05a72 --- /dev/null +++ b/codes/luowei/15609646.java @@ -0,0 +1,19 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; 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 diff --git a/codes/luox12/15700214.java b/codes/luox12/15700214.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/luox12/15700214.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/luzhanheng2023/12213445.java b/codes/luzhanheng2023/12213445.java new file mode 100644 index 0000000000000000000000000000000000000000..4ad17961517430007d1a719aed3e103b4c9133ce --- /dev/null +++ b/codes/luzhanheng2023/12213445.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < a.length; i++) { + for (int j = i+1; j < a.length; j++) { + if (a[i] > a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } + } \ No newline at end of file diff --git a/codes/lvbin2/.keep b/codes/lvbin2/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/lvbin2/15758178.java b/codes/lvbin2/15758178.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/lvbin2/15758178.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/lvlv123/15693242.java b/codes/lvlv123/15693242.java new file mode 100644 index 0000000000000000000000000000000000000000..515548eef4bc997e70c18f45d615c42e68ad4647 --- /dev/null +++ b/codes/lvlv123/15693242.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 通过多次遍历数组,每次比较相邻的元素,如果它们的顺序错误就把它们交换过来。 + * 遍历数组的工作是重复地进行直到没有再需要交换,也就是说该数组已经排序完成。 + * @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 - 1 - i; j++) { // 内层循环负责具体的元素比较和交换 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们 + // 使用临时变量进行交换 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/lvxl111/15528312.java b/codes/lvxl111/15528312.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/lvxl111/15528312.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/lx1122334/12138905.java b/codes/lx1122334/12138905.java new file mode 100644 index 0000000000000000000000000000000000000000..8501963bbb87f4b03299f60e8aba7a3af3251f61 --- /dev/null +++ b/codes/lx1122334/12138905.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 + diff --git a/codes/lxnb666/14201242.java b/codes/lxnb666/14201242.java new file mode 100644 index 0000000000000000000000000000000000000000..10dbc6525b8c4427dda5055b3f3c224c68398d2c --- /dev/null +++ b/codes/lxnb666/14201242.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end diff --git a/codes/lynlon/12376594.java b/codes/lynlon/12376594.java new file mode 100644 index 0000000000000000000000000000000000000000..4631f6cf74c4c376ce4f2c20f917e9f801f87be7 --- /dev/null +++ b/codes/lynlon/12376594.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp; + for(int i=0;ia[j+1]){ + temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} //end diff --git a/codes/lzf1123/15542355.java b/codes/lzf1123/15542355.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/lzf1123/15542355.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/lzr565520/15742467.java b/codes/lzr565520/15742467.java new file mode 100644 index 0000000000000000000000000000000000000000..2252b818e6125ed4f8bbd23eca03c12c15ca1757 --- /dev/null +++ b/codes/lzr565520/15742467.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/m88888686/11201957.java b/codes/m88888686/11201957.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/m88888686/11201957.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ma_yin/15529443.java b/codes/ma_yin/15529443.java new file mode 100644 index 0000000000000000000000000000000000000000..61c422b629e86de0017a8c4de128f6973bd290c9 --- /dev/null +++ b/codes/ma_yin/15529443.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/mabofu/10606075.java b/codes/mabofu/10606075.java new file mode 100644 index 0000000000000000000000000000000000000000..2fd061282a80d9eeaf57831e9e371f129c3915f4 --- /dev/null +++ b/codes/mabofu/10606075.java @@ -0,0 +1,25 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 1; i < a.length; i++) { + boolean flag = true; + for (int j = 0; j < a.length - 1; j++) { + if (a[j] > a[j + 1]) { + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + flag = false; + } + } + if (flag) { + break; + } + } + +} //end + diff --git a/codes/macw_379/15655907.java b/codes/macw_379/15655907.java new file mode 100644 index 0000000000000000000000000000000000000000..09d26b4c17225cab897586309217bbdab55ab152 --- /dev/null +++ b/codes/macw_379/15655907.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 依次比较相邻的元素,如果它们的顺序错误就把它们交换过来 + * @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 - 1 - i; j++) { // 内层循环,控制每一趟排序多少次 + // 如果前一个元素大于后一个元素,则交换位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; // 使用临时变量进行交换 + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/mafuqiang/10166179.java b/codes/mafuqiang/10166179.java new file mode 100644 index 0000000000000000000000000000000000000000..4b18be751186d0fdb6fb1f93c30403590a8ea1be --- /dev/null +++ b/codes/mafuqiang/10166179.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + + int temp; + for(int i=0;ia[j+1]){ + temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } + +} //end diff --git a/codes/mahaoliang/15538747.java b/codes/mahaoliang/15538747.java new file mode 100644 index 0000000000000000000000000000000000000000..e125768f7a0efc8ad7be883af8dc49704ed77a31 --- /dev/null +++ b/codes/mahaoliang/15538747.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/mahaoliang/15540967.java b/codes/mahaoliang/15540967.java new file mode 100644 index 0000000000000000000000000000000000000000..4d6e2d6a741fcb972e0013229d90dd1bfeb282bd --- /dev/null +++ b/codes/mahaoliang/15540967.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/maisaki/15487137.java b/codes/maisaki/15487137.java new file mode 100644 index 0000000000000000000000000000000000000000..6a3fea3736126b68d3f99379af3c5a4cf2e5360a --- /dev/null +++ b/codes/maisaki/15487137.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + for (i = 0; i < n-1; i++) { + for (j = 0; j < n-1-i; j++) { + if (a[j] > a[j+1]) { + int t = a[j]; + a[j] = a[j+1]; + a[j+1] = t; + } + } + } + +} //end diff --git a/codes/maiswemlilo1/11241067.java b/codes/maiswemlilo1/11241067.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/maiswemlilo1/11241067.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/maqingshan123/15622329.java b/codes/maqingshan123/15622329.java new file mode 100644 index 0000000000000000000000000000000000000000..51a5e05b9f16f21ec609dc7eb8402d040e6734d0 --- /dev/null +++ b/codes/maqingshan123/15622329.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 将数组a从小到大进行排序 + * @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 + diff --git a/codes/matrixsquad/.keep b/codes/matrixsquad/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/matrixsquad/15774031.java b/codes/matrixsquad/15774031.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/matrixsquad/15774031.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/maxsky010/15734024.java b/codes/maxsky010/15734024.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec373aee12c8b4795c0d670e772620e90ee630e --- /dev/null +++ b/codes/maxsky010/15734024.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/mcfly001/11350844.java b/codes/mcfly001/11350844.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/mcfly001/11350844.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/memuqee/11238999.java b/codes/memuqee/11238999.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/memuqee/11238999.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/meng123/15699639.java b/codes/meng123/15699639.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/meng123/15699639.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/mengwenxu/15578436.java b/codes/mengwenxu/15578436.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/mengwenxu/15578436.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/menmazqj/15277745.java b/codes/menmazqj/15277745.java new file mode 100644 index 0000000000000000000000000000000000000000..37b3920b01f5b5e1a2d632f569dfbdcc988af812 --- /dev/null +++ b/codes/menmazqj/15277745.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 diff --git a/codes/mewchen/.keep b/codes/mewchen/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/mewchen/10042032.java b/codes/mewchen/10042032.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/mewchen/10042032.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/milkyTea/11201805.java b/codes/milkyTea/11201805.java new file mode 100644 index 0000000000000000000000000000000000000000..47680171357df4926dc02873c8b8244657a0f30b --- /dev/null +++ b/codes/milkyTea/11201805.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 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 diff --git a/codes/mimeik/14612577.java b/codes/mimeik/14612577.java new file mode 100644 index 0000000000000000000000000000000000000000..f723595341a74d31d963f92d96339a161c067a31 --- /dev/null +++ b/codes/mimeik/14612577.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 1111 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end diff --git a/codes/mingt123/15699576.java b/codes/mingt123/15699576.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/mingt123/15699576.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/minixin/11115487.java b/codes/minixin/11115487.java new file mode 100644 index 0000000000000000000000000000000000000000..823354248ac46c3e3650f1c6dd3e0d62c7ad26cd --- /dev/null +++ b/codes/minixin/11115487.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/mjzhutianxiu/15555031.java b/codes/mjzhutianxiu/15555031.java new file mode 100644 index 0000000000000000000000000000000000000000..49a64aea87954797dbd63b42f729d278ffbafca1 --- /dev/null +++ b/codes/mjzhutianxiu/15555031.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j, tmp_data; + + for(i = 0; i < n - 1; i ++) { + for(j = 0; j < n - 1 - i; j ++) { + if(a[j] > a[j + 1]) { + tmp_data = a[j + 1]; + a[j + 1] = a[j]; + a[j] = tmp_data; + } + } + } +} //end diff --git a/codes/mjzhutianxiu/15578951.java b/codes/mjzhutianxiu/15578951.java new file mode 100644 index 0000000000000000000000000000000000000000..49a64aea87954797dbd63b42f729d278ffbafca1 --- /dev/null +++ b/codes/mjzhutianxiu/15578951.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j, tmp_data; + + for(i = 0; i < n - 1; i ++) { + for(j = 0; j < n - 1 - i; j ++) { + if(a[j] > a[j + 1]) { + tmp_data = a[j + 1]; + a[j + 1] = a[j]; + a[j] = tmp_data; + } + } + } +} //end diff --git a/codes/mmm111/15648151.java b/codes/mmm111/15648151.java new file mode 100644 index 0000000000000000000000000000000000000000..04625a494ce3da760397a3c3c648cdbe5d0bfa71 --- /dev/null +++ b/codes/mmm111/15648151.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end + diff --git a/codes/mmm123456/15625950.java b/codes/mmm123456/15625950.java new file mode 100644 index 0000000000000000000000000000000000000000..efccdd392a01ad6c4c94f113aeea500c9578d82e --- /dev/null +++ b/codes/mmm123456/15625950.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 0; j < n - i - 1; ++j) { + if(a[j] > a[j + 1]) { + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end diff --git a/codes/mmmmmm/11121934.java b/codes/mmmmmm/11121934.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/mmmmmm/11121934.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/mmnn123/15720368.java b/codes/mmnn123/15720368.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/mmnn123/15720368.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/momo1234/15630942.java b/codes/momo1234/15630942.java new file mode 100644 index 0000000000000000000000000000000000000000..15c23e4b3394070df3dad91a9611a0863cc3c696 --- /dev/null +++ b/codes/momo1234/15630942.java @@ -0,0 +1,29 @@ +/** + * 冒泡排序函数 + * 冒泡排序是一种简单的排序算法,它重复地遍历要排序的数列,一次比较两个元素, + * 如果他们的顺序错误就把他们交换过来。遍历数列的工作是重复地进行直到没有再需要交换, + * 也就是说该数列已经排序完成。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 标记变量,用于检测是否发生过交换,如果没有交换则数组已经有序 + boolean swapped = false; + for (int j = 0; j < n - i - 1; j++) { + // 如果前一个元素大于后一个元素,则交换他们的位置 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + // 标记本轮发生过交换 + swapped = true; + } + } + // 如果本轮没有发生过交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/momozi/15562400.java b/codes/momozi/15562400.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/momozi/15562400.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/moyu9527/15633448.java b/codes/moyu9527/15633448.java new file mode 100644 index 0000000000000000000000000000000000000000..26233d1660024e6554130ef03f6135cab4693de2 --- /dev/null +++ b/codes/moyu9527/15633448.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 将数组中的元素按照从小到大的顺序排列 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j + 1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/mr_lk123/.java b/codes/mr_lk123/.java new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/mr_lk123/9954396.java b/codes/mr_lk123/9954396.java new file mode 100644 index 0000000000000000000000000000000000000000..82b73c8ff8181a822b4e5b9b4a74866761c7b1ca --- /dev/null +++ b/codes/mr_lk123/9954396.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end + diff --git a/codes/msc12345678/15659945.java b/codes/msc12345678/15659945.java new file mode 100644 index 0000000000000000000000000000000000000000..558a2b69735e20a59a6b0e2d8629da73a39da82f --- /dev/null +++ b/codes/msc12345678/15659945.java @@ -0,0 +1,12 @@ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { // 外层循环控制所有元素遍历的次数 + for (int j = 0; j < n - 1 - i; j++) { // 内层循环控制相邻元素两两比较 + if (a[j] > a[j + 1]) { // 如果当前元素大于下一个元素,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/msk6527/15520710.java b/codes/msk6527/15520710.java new file mode 100644 index 0000000000000000000000000000000000000000..d7fbec1bd5b39dee2d383d4d20f8690284d526d4 --- /dev/null +++ b/codes/msk6527/15520710.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 对数组进行冒泡排序,将无序数组变为有序数组 + * @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 - 1 - i; j++) { // 内层循环,从前往后依次比较相邻的两个元素 + if (a[j] > a[j + 1]) { // 如果前一个元素比后一个元素大,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/mtfx0516/15585376.java b/codes/mtfx0516/15585376.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/mtfx0516/15585376.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/mupimage/11254168.java b/codes/mupimage/11254168.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/mupimage/11254168.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/mwy280429/15517713.java b/codes/mwy280429/15517713.java new file mode 100644 index 0000000000000000000000000000000000000000..4e7bebd733aa293f3502062974e4c36accba4b11 --- /dev/null +++ b/codes/mwy280429/15517713.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * @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]) { + // 交换 a[j+1] 和 a[j] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/myclubocr/11122342.java b/codes/myclubocr/11122342.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/myclubocr/11122342.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/nbdopa/11116411.java b/codes/nbdopa/11116411.java new file mode 100644 index 0000000000000000000000000000000000000000..d34027face05a4c77a2a35deae63795bb9c58f79 --- /dev/null +++ b/codes/nbdopa/11116411.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + if(a == null || a.length == 0){ + return; + } + for(int i = 0; i< n; i++){ + boolean flag = true; + for(int j = 0; j< n - i - 1 ; j++){ + if(a[j]> a[j+1]){ + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + flag = false; + } + } + if(flag){ + break; + } + + } +} //end \ No newline at end of file diff --git a/codes/ndliang/15628397.java b/codes/ndliang/15628397.java new file mode 100644 index 0000000000000000000000000000000000000000..41479c77912bd67627ed1ee874e22f7fe1ddd9e6 --- /dev/null +++ b/codes/ndliang/15628397.java @@ -0,0 +1,18 @@ + +/** + * 冒泡排序函数 + * 这是一个经典的排序算法,通过不断比较相邻的元素,将较大的元素往后移动,实现数组的升序排序。 + * @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 - 1 - i; j++) { // 内层循环负责两两比较 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/ne8848/11116344.java b/codes/ne8848/11116344.java new file mode 100644 index 0000000000000000000000000000000000000000..823354248ac46c3e3650f1c6dd3e0d62c7ad26cd --- /dev/null +++ b/codes/ne8848/11116344.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/neineiya/11260235.java b/codes/neineiya/11260235.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/neineiya/11260235.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/nemolv/15195393.java b/codes/nemolv/15195393.java new file mode 100644 index 0000000000000000000000000000000000000000..c85755c9b21fd63adaaaea9c767573a42bd6ce7d --- /dev/null +++ b/codes/nemolv/15195393.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + //外部循环控制排序的趟数。冒泡排序的每一趟会将最大的元素"冒泡"到数组的末尾,因此需要执行 n-1 趟,其中 n 是元素的总数 + for (int i = 0; i < n - 1; i++) { + //内循环控制每趟比较的次数。由于每一趟都会将一个最大的元素沉到数组末尾,所以内循环次数逐渐减小。 + for (int j = 0; j < n - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换arr[j]和arr[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + +} //end diff --git a/codes/nigger/15601489.java b/codes/nigger/15601489.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/nigger/15601489.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/nightowl/9959740.java b/codes/nightowl/9959740.java new file mode 100644 index 0000000000000000000000000000000000000000..4f93d09f6ee55c29cfd8c0af38a103f9a34f55b1 --- /dev/null +++ b/codes/nightowl/9959740.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * + * @param arr 待排序的数组 + * @param len 待排序的数组长度 + */ + public static void bubbleSort(int[] arr, int len) { + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < len - 1; i++) { + //对数组进行遍历,相邻的两个数字进行比较,每次比较之后数字总数就会减一防止索引越界,让长度减一 + for (int j = 0; j < len - 1 - i; j++) { + //判断每两个相邻的数字,大的往前排 + if (arr[j] >= arr[j + 1]) { + int temp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = temp; + } + } + } + } //end diff --git a/codes/niyiyi/15684167.java b/codes/niyiyi/15684167.java new file mode 100644 index 0000000000000000000000000000000000000000..54c5f3869cd16ee9e7c2b77895a39fae63f05dbc --- /dev/null +++ b/codes/niyiyi/15684167.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy \ No newline at end of file diff --git a/codes/njjkxllj/15631418.java b/codes/njjkxllj/15631418.java new file mode 100644 index 0000000000000000000000000000000000000000..ad6fb35f9bcbc22c336cd0851d9676f65b5b7676 --- /dev/null +++ b/codes/njjkxllj/15631418.java @@ -0,0 +1,22 @@ + +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0;ia[j+1]){ + int temp=a[j+1]; + a[j+1]=a[j]; + a[j]=temp; + } + } + } + return a; +} //end + + diff --git a/codes/no8gcoder/15578057.java b/codes/no8gcoder/15578057.java new file mode 100644 index 0000000000000000000000000000000000000000..acec583fb811e1f577adcdc5c0236228369b994f --- /dev/null +++ b/codes/no8gcoder/15578057.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 对数组进行冒泡排序,从小到大排序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/ny960126/15626345.java b/codes/ny960126/15626345.java new file mode 100644 index 0000000000000000000000000000000000000000..354c65d87e3457604a386f0a99f2c10a07314d5c --- /dev/null +++ b/codes/ny960126/15626345.java @@ -0,0 +1,12 @@ +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]){ + //交换a[j]和a[j + 1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/o11ccm/.keep b/codes/o11ccm/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/o11ccm/10041751.java b/codes/o11ccm/10041751.java new file mode 100644 index 0000000000000000000000000000000000000000..c031d21af6fe2736fb18f2152a78025d14914262 --- /dev/null +++ b/codes/o11ccm/10041751.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/o1982016781/11118518.java b/codes/o1982016781/11118518.java new file mode 100644 index 0000000000000000000000000000000000000000..37e8a08faccdeeae78deb95416f0867067181b74 --- /dev/null +++ b/codes/o1982016781/11118518.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] b, int n) { + for (int i=0 ; ib[j+1]) { + int temp=b[j]; + b[j]=b[j+1]; + b[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/o389675/15718177.java b/codes/o389675/15718177.java new file mode 100644 index 0000000000000000000000000000000000000000..ef30d22d184d51c4a9e71595baebc5b69eed29a5 --- /dev/null +++ b/codes/o389675/15718177.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 通过相邻元素之间的比较和交换,使得每一轮循环后最大(或最小)的元素能够“冒泡”到数组的末尾。 + * @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 - 1 - i; j++) { // 内层循环控制每一趟排序的过程 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/obc147/11064483.java b/codes/obc147/11064483.java new file mode 100644 index 0000000000000000000000000000000000000000..823354248ac46c3e3650f1c6dd3e0d62c7ad26cd --- /dev/null +++ b/codes/obc147/11064483.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/onenewcode/15333872.java b/codes/onenewcode/15333872.java new file mode 100644 index 0000000000000000000000000000000000000000..0124a74c194bf08ed6e40679fe15f1bbf900e976 --- /dev/null +++ b/codes/onenewcode/15333872.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/ooooo_long/15253355.java b/codes/ooooo_long/15253355.java new file mode 100644 index 0000000000000000000000000000000000000000..ecfb06f78761be02481338cc4e8e079a30facc5f --- /dev/null +++ b/codes/ooooo_long/15253355.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 diff --git a/codes/ooooo_long/15256718.java b/codes/ooooo_long/15256718.java new file mode 100644 index 0000000000000000000000000000000000000000..ecfb06f78761be02481338cc4e8e079a30facc5f --- /dev/null +++ b/codes/ooooo_long/15256718.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 diff --git a/codes/ooopen/11302831.java b/codes/ooopen/11302831.java new file mode 100644 index 0000000000000000000000000000000000000000..029e9d84c1474520908887693e69aabcb7ff0aba --- /dev/null +++ b/codes/ooopen/11302831.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 +*/ +public static void bubbleSort(int [] a, int n){ + int j , k; + int flag = n ;//flag来记录最后交换的位置,也就是排序的尾边界 + + while (flag > 0){//排序未结束标志 + k = flag; //k 来记录遍历的尾边界 + flag = 0; + + for(j=1; j a[j]){//前面的数字大于后面的数字就交换 + //交换a[j-1]和a[j] + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j]=temp; + + //表示交换过数据; + flag = j;//记录最新的尾边界. + } + } + } +} \ No newline at end of file diff --git a/codes/openAI12/11234314.java b/codes/openAI12/11234314.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/openAI12/11234314.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/openAsg/11491517.java b/codes/openAsg/11491517.java new file mode 100644 index 0000000000000000000000000000000000000000..e614b8982a7289050015e820483647564f08204b --- /dev/null +++ b/codes/openAsg/11491517.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 tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + } + } + } +} //end diff --git a/codes/openCI/11276263.java b/codes/openCI/11276263.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/openCI/11276263.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/openanolis_idear/.keep b/codes/openanolis_idear/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/openanolis_idear/15698658.java b/codes/openanolis_idear/15698658.java new file mode 100644 index 0000000000000000000000000000000000000000..8c7e1b661dc7b1c6a82c3a8f52adfc195c89691e --- /dev/null +++ b/codes/openanolis_idear/15698658.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/opsation/11293380.java b/codes/opsation/11293380.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/opsation/11293380.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/oroyade/11207786.java b/codes/oroyade/11207786.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/oroyade/11207786.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/os1024/10038969.java b/codes/os1024/10038969.java new file mode 100644 index 0000000000000000000000000000000000000000..ddf126977df78e84c464e93955d733ea1d3239d3 --- /dev/null +++ b/codes/os1024/10038969.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + int i, j; + + for (i = n - 1; i > 0; i--) { + // 将a[0...i]中最大的数据放在末尾 + for (j = 0; j < i; j++) { + + if (a[j] > a[j + 1]) { + // 交换a[j]和a[j+1] + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} diff --git a/codes/owccqq/11122165.java b/codes/owccqq/11122165.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/owccqq/11122165.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/oyoumq/11452053.java b/codes/oyoumq/11452053.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/oyoumq/11452053.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/p13285288040/.keep b/codes/p13285288040/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/p13285288040/10972084.java b/codes/p13285288040/10972084.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/p13285288040/10972084.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/p2948642664/15730688.java b/codes/p2948642664/15730688.java new file mode 100644 index 0000000000000000000000000000000000000000..bb5a808a30615e8da5bae9fedecedab071470ef1 --- /dev/null +++ b/codes/p2948642664/15730688.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 依次比较相邻的元素,如果它们的顺序错误就把它们交换过来 + * @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 - 1 - i; j++) { // 内层循环控制每一趟排序多少次 + if (a[j] > a[j + 1]) { // 如果当前元素大于下一个元素,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/passass/11299378.java b/codes/passass/11299378.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/passass/11299378.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/pcvvvc/11211727.java b/codes/pcvvvc/11211727.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/pcvvvc/11211727.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/philips/11302813.java b/codes/philips/11302813.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/philips/11302813.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/pictur/15653765.java b/codes/pictur/15653765.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/pictur/15653765.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/plugin/11199950.java b/codes/plugin/11199950.java new file mode 100644 index 0000000000000000000000000000000000000000..862a031b6f73aac6e6e6656df710e9caa439d4c0 --- /dev/null +++ b/codes/plugin/11199950.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int m=0 ; ma[q+1]) { + int temp=a[q]; + a[q]=a[q+1]; + a[q+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/plustub/11244425.java b/codes/plustub/11244425.java new file mode 100644 index 0000000000000000000000000000000000000000..191de91d18bdb330ab1609aaa3b20eeb19226481 --- /dev/null +++ b/codes/plustub/11244425.java @@ -0,0 +1,11 @@ + public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < a.length - 1; i++) { + for (int j = 0; j < a.length - 1 - i; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j + 1]; + a[j + 1] = a[j]; + a[j] = temp; + } + } + } + } \ No newline at end of file diff --git a/codes/pondfish/15535613.java b/codes/pondfish/15535613.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/pondfish/15535613.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/ppdplius/11212528.java b/codes/ppdplius/11212528.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/ppdplius/11212528.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/promse/11152350.java b/codes/promse/11152350.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/promse/11152350.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/pui9001/11232878.java b/codes/pui9001/11232878.java new file mode 100644 index 0000000000000000000000000000000000000000..deb2438785c696d09e985c35997c2f2bc5445a90 --- /dev/null +++ b/codes/pui9001/11232878.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/pumpkin/15658869.java b/codes/pumpkin/15658869.java new file mode 100644 index 0000000000000000000000000000000000000000..2571c1de5aa50b72ed9f3720cfb0d5463b9bbfa5 --- /dev/null +++ b/codes/pumpkin/15658869.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 通过重复地遍历要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 + * 遍历数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/q1229173945/15755759.java b/codes/q1229173945/15755759.java new file mode 100644 index 0000000000000000000000000000000000000000..d18a9e37b6597397e15055f4b8171b58e2e97989 --- /dev/null +++ b/codes/q1229173945/15755759.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 冒泡排序是一种简单的排序算法,它重复地遍历要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 + * @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 - 1 - i; j++) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/q6666666868/11202065.java b/codes/q6666666868/11202065.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/q6666666868/11202065.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/qianshi/13339610.java b/codes/qianshi/13339610.java new file mode 100644 index 0000000000000000000000000000000000000000..03527ec51557b75d2620ae5963c4a0415fefbedd --- /dev/null +++ b/codes/qianshi/13339610.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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end \ No newline at end of file diff --git a/codes/qianxiaxingkong/11737212.java b/codes/qianxiaxingkong/11737212.java new file mode 100644 index 0000000000000000000000000000000000000000..adf2deb6624f6dd0dc6003418c7b47e1ccd8bcab --- /dev/null +++ b/codes/qianxiaxingkong/11737212.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * @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; + } + } + } +} + + diff --git a/codes/qichang0921/15671954.java b/codes/qichang0921/15671954.java new file mode 100644 index 0000000000000000000000000000000000000000..e19af71f108d7db632940367ec2223352b2c268c --- /dev/null +++ b/codes/qichang0921/15671954.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * 通过重复遍历待排序的数组,比较相邻的元素并交换它们(如果它们在错误的顺序), + * 直到没有更多的交换需要,即该数组已经排序。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { // 外层循环控制排序的趟数 + boolean swapped = false; // 用于标记某一趟是否发生了交换 + 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; + swapped = true; // 标记发生了交换 + } + } + if (!swapped) { // 如果某一趟没有发生交换,说明数组已经有序,可以提前退出 + break; + } + } +} // end diff --git a/codes/qigela/.keep b/codes/qigela/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/qigela/15757052.java b/codes/qigela/15757052.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/qigela/15757052.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/qihuan/15568203.java b/codes/qihuan/15568203.java new file mode 100644 index 0000000000000000000000000000000000000000..ac777e0f6e97b292b44a342bd96e492821d3bcf0 --- /dev/null +++ b/codes/qihuan/15568203.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 功能:对输入的整数数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/qingfeng/15541061.java b/codes/qingfeng/15541061.java new file mode 100644 index 0000000000000000000000000000000000000000..ecf81b2384b0ce0e49ba9161c4de669ecfab4499 --- /dev/null +++ b/codes/qingfeng/15541061.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 diff --git a/codes/qjpdjk578/15514740.java b/codes/qjpdjk578/15514740.java new file mode 100644 index 0000000000000000000000000000000000000000..4dd34424096923bb2ea92237e532df3550527ca7 --- /dev/null +++ b/codes/qjpdjk578/15514740.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + if (n <= 1) { + return; // 如果数组长度小于等于1,则不需要排序 + } + + for (int i = 0; i < n; ++i) { + // 提前退出冒泡循环的标志位 + boolean flag = false; + 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; + flag = true; // 表示有数据交换 + } + } + if (!flag) break; // 没有数据交换,提前退出 + } +} //end diff --git a/codes/qq753755635/15717531.java b/codes/qq753755635/15717531.java new file mode 100644 index 0000000000000000000000000000000000000000..45a9d6a25b7c1209865c364661c1425ed9ae889d --- /dev/null +++ b/codes/qq753755635/15717531.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 功能:对给定的整数数组进行冒泡排序 + * @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 diff --git a/codes/qwaszx/15543578.java b/codes/qwaszx/15543578.java new file mode 100644 index 0000000000000000000000000000000000000000..e62ce2203114b40feac1bd75c98c93cd04d1116b --- /dev/null +++ b/codes/qwaszx/15543578.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/qwerplm6/15587872.java b/codes/qwerplm6/15587872.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/qwerplm6/15587872.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/qwert4678/.keep b/codes/qwert4678/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/qwert4678/15743469.java b/codes/qwert4678/15743469.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/qwert4678/15743469.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/renhaihang/15681912.java b/codes/renhaihang/15681912.java new file mode 100644 index 0000000000000000000000000000000000000000..92c1bacfe9158fca1077809b7a8e0f6cb00aa693 --- /dev/null +++ b/codes/renhaihang/15681912.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较并交换位置,使得每一轮循环后最大(或最小)的元素被交换到数组的末尾。 + * @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 diff --git a/codes/replying/11277017.java b/codes/replying/11277017.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/replying/11277017.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/rhp1234/15674333.java b/codes/rhp1234/15674333.java new file mode 100644 index 0000000000000000000000000000000000000000..5538e5d1293148ee7fae27f92ae9e7e13a70ff22 --- /dev/null +++ b/codes/rhp1234/15674333.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * 该函数通过冒泡排序算法对整数数组进行升序排序 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 用于标记是否发生交换,以优化排序过程 + boolean swapped = false; + 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; + // 标记发生了交换 + swapped = true; + } + } + // 如果没有发生交换,则数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/rice18302947981/15717388.java b/codes/rice18302947981/15717388.java new file mode 100644 index 0000000000000000000000000000000000000000..a72d8eb5b560b007e3c507b0d5e6073e090ef223 --- /dev/null +++ b/codes/rice18302947981/15717388.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j + 1] 的值 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/robert_bo/15545727.java b/codes/robert_bo/15545727.java new file mode 100644 index 0000000000000000000000000000000000000000..4370113dd42e84bd1670bb0d8a848c92f05d43f4 --- /dev/null +++ b/codes/robert_bo/15545727.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/robert_bo/15669897.java b/codes/robert_bo/15669897.java new file mode 100644 index 0000000000000000000000000000000000000000..72e7f26afa817f34a5b016310ff8ab93be613b41 --- /dev/null +++ b/codes/robert_bo/15669897.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/robert_bo/15669960.java b/codes/robert_bo/15669960.java new file mode 100644 index 0000000000000000000000000000000000000000..85112f922ea0d1d95dfdce27442cbe56693dacc6 --- /dev/null +++ b/codes/robert_bo/15669960.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/roklly/11207828.java b/codes/roklly/11207828.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/roklly/11207828.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/root0day/10353744.java b/codes/root0day/10353744.java new file mode 100644 index 0000000000000000000000000000000000000000..33f024280ec9e03701cc23cb42410308718b4ed9 --- /dev/null +++ b/codes/root0day/10353744.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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 = i+1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[i]; + a[i] = a[j]; + a[j] = temp; + } + } + } +} //end diff --git a/codes/rree123/15719870.java b/codes/rree123/15719870.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/rree123/15719870.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/rtsp8080/11303570.java b/codes/rtsp8080/11303570.java new file mode 100644 index 0000000000000000000000000000000000000000..24b49b4b1fd01d1f21be8b362a582158452e41d3 --- /dev/null +++ b/codes/rtsp8080/11303570.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/ryer767gfgs/.keep b/codes/ryer767gfgs/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/ryer767gfgs/15743395.java b/codes/ryer767gfgs/15743395.java new file mode 100644 index 0000000000000000000000000000000000000000..96508c1385b4a62859a2adea3c8dfae39051b7cd --- /dev/null +++ b/codes/ryer767gfgs/15743395.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/s0nder/15635858.java b/codes/s0nder/15635858.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/s0nder/15635858.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/s18836251852/15717550.java b/codes/s18836251852/15717550.java new file mode 100644 index 0000000000000000000000000000000000000000..06f37284a2ef346036f7727ab7275454f55e382c --- /dev/null +++ b/codes/s18836251852/15717550.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 对数组a进行冒泡排序,使其变得有序 + * @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 - 1 - i; j++){ // 内层循环,负责每趟的排序 + if(a[j] > a[j + 1]){ // 如果前一个元素比后一个元素大,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/s20050520/15545690.java b/codes/s20050520/15545690.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/s20050520/15545690.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/sad546aa/.keep b/codes/sad546aa/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/sad546aa/15743452.java b/codes/sad546aa/15743452.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/sad546aa/15743452.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/sadboy/10979809.java b/codes/sadboy/10979809.java new file mode 100644 index 0000000000000000000000000000000000000000..653d850387c460844b7367ff2738e07559ec338d --- /dev/null +++ b/codes/sadboy/10979809.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp = 0; + for (int i = 0; i < arr.length-1; i++) { + for (int j = 0; j < arr.length-1 -i; j++) { + if (arr[j] > arr[j+1]){ + temp = arr[j]; + arr[j] = arr[j+1]; + arr[j+1] = temp; + } + } + } + +} //end diff --git a/codes/sadboy/15628230.java b/codes/sadboy/15628230.java new file mode 100644 index 0000000000000000000000000000000000000000..c50ecb8b64ada397f8b3038d214d92b22037e169 --- /dev/null +++ b/codes/sadboy/15628230.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int sad = 0; sad < n - i - 1; sad++) { + if(a[sad] > a[sad + 1]) { + int temp = a[sad]; + a [sad] = a[sad + 1]; + a[sad + 1] = temp; + } + } + } + + +} //end,sad diff --git a/codes/saf546qafd/.keep b/codes/saf546qafd/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/saf546qafd/15743461.java b/codes/saf546qafd/15743461.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/saf546qafd/15743461.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/safasf342351/.keep b/codes/safasf342351/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/safasf342351/15743467.java b/codes/safasf342351/15743467.java new file mode 100644 index 0000000000000000000000000000000000000000..96508c1385b4a62859a2adea3c8dfae39051b7cd --- /dev/null +++ b/codes/safasf342351/15743467.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/saffasckkk77/.keep b/codes/saffasckkk77/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/saffasckkk77/15743383.java b/codes/saffasckkk77/15743383.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/saffasckkk77/15743383.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/sahofav587/11220243.java b/codes/sahofav587/11220243.java new file mode 100644 index 0000000000000000000000000000000000000000..deb2438785c696d09e985c35997c2f2bc5445a90 --- /dev/null +++ b/codes/sahofav587/11220243.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/sakut2/15592208.java b/codes/sakut2/15592208.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/sakut2/15592208.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/sam9029/.java.swp b/codes/sam9029/.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..b94c1c39673fe39ba0f06402fd2d196d3e8aff1d Binary files /dev/null and b/codes/sam9029/.java.swp differ diff --git a/codes/sam9029/9968905.java b/codes/sam9029/9968905.java new file mode 100644 index 0000000000000000000000000000000000000000..4817bae9fa4f89646d2cff5f41720e13747a1f6b --- /dev/null +++ b/codes/sam9029/9968905.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + //变量 + int template = 0; // 交换变量 + + for(int i = 0; i < n-1; i++){ + for(int j = 0;j < n-1-i; j ++){ + if(a[j] > a[j+1]){ + template = a[j]; + a[j] = a[j+1]; + a[j+1] = template; + } + } + } + +} //end + diff --git a/codes/samzoe_openanolis/15733701.java b/codes/samzoe_openanolis/15733701.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec373aee12c8b4795c0d670e772620e90ee630e --- /dev/null +++ b/codes/samzoe_openanolis/15733701.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/sandbox/11142279.java b/codes/sandbox/11142279.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/sandbox/11142279.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/sangeta/.keep b/codes/sangeta/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/sangeta/15720730.java b/codes/sangeta/15720730.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/sangeta/15720730.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/sanya123/15772128.java b/codes/sanya123/15772128.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/sanya123/15772128.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/sayslot/11250439.java b/codes/sayslot/11250439.java new file mode 100644 index 0000000000000000000000000000000000000000..7db1ed71c900652c30e8b1c3e9172e685287856a --- /dev/null +++ b/codes/sayslot/11250439.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int []arr, int n) { + 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+1]; + arr[j+1] = arr[j]; + arr[j] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/sdafaf4251/.keep b/codes/sdafaf4251/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/sdafaf4251/15743466.java b/codes/sdafaf4251/15743466.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/sdafaf4251/15743466.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/sdasr5542/.keep b/codes/sdasr5542/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/sdasr5542/15743114.java b/codes/sdasr5542/15743114.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/sdasr5542/15743114.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/sdt345sdfs/.keep b/codes/sdt345sdfs/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/sdt345sdfs/15743451.java b/codes/sdt345sdfs/15743451.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/sdt345sdfs/15743451.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/selena/11289878.java b/codes/selena/11289878.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/selena/11289878.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/seven/15710966.java b/codes/seven/15710966.java new file mode 100644 index 0000000000000000000000000000000000000000..c57f5a28e74c7ae4f1e34a718bae3a949a985798 --- /dev/null +++ b/codes/seven/15710966.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { // 外层循环,控制排序的轮数 + // i 表示当前已经排序好的元素个数,因此每一轮排序后,最大的元素会移到正确的位置 + for (int j = 0; j < n - i - 1; j++) { // 内层循环,控制每轮中比较的次数 + // j 表示当前比较的元素索引,从0开始到n-i-2,因为最后i个元素已经是排序好的 + if (a[j] > a[j + 1]) { // 如果当前元素大于下一个元素 + // 则交换这两个元素的位置,保证较大的元素向数组的末尾移动 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; // 使用临时变量temp存储a[j]的值 + a[j] = a[j + 1]; // 将a[j+1]的值赋给a[j] + a[j + 1] = temp; // 将temp(即原来的a[j]的值)赋给a[j+1] + } + } + } +} // end bubbleSort函数 diff --git a/codes/sevenpppplus/10371725.java b/codes/sevenpppplus/10371725.java new file mode 100644 index 0000000000000000000000000000000000000000..df0dbf5958c1aaad83774cbae4587bb05295c074 --- /dev/null +++ b/codes/sevenpppplus/10371725.java @@ -0,0 +1,20 @@ + /** + * 冒泡排序函数 + * 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.println("冒泡升序排序后的结果是:"); + for (int j : a) System.out.print(j + " "); + } //end diff --git a/codes/sfdafas422/.keep b/codes/sfdafas422/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/sfdafas422/15743380.java b/codes/sfdafas422/15743380.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/sfdafas422/15743380.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/sgdfg56/.keep b/codes/sgdfg56/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/sgdfg56/15743475.java b/codes/sgdfg56/15743475.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/sgdfg56/15743475.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/shangxing117/.keep b/codes/shangxing117/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/shangxing117/15742267.java b/codes/shangxing117/15742267.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/shangxing117/15742267.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/sharpery/15562912.java b/codes/sharpery/15562912.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/sharpery/15562912.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/shelove/11217672.java b/codes/shelove/11217672.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/shelove/11217672.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/shiguang173/15759081.java b/codes/shiguang173/15759081.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/shiguang173/15759081.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/shihantao/.keep b/codes/shihantao/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/shihantao/10039704.java b/codes/shihantao/10039704.java new file mode 100644 index 0000000000000000000000000000000000000000..e3648990e052e84b9e5ca5b1f2e0b460f51565c5 --- /dev/null +++ b/codes/shihantao/10039704.java @@ -0,0 +1,17 @@ + /* 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +} //end \ No newline at end of file diff --git a/codes/shihantao1/.keep b/codes/shihantao1/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/shiove/15669581.java b/codes/shiove/15669581.java new file mode 100644 index 0000000000000000000000000000000000000000..7b731aa8a6ac71c95b29596dcb437b8becdf2cb7 --- /dev/null +++ b/codes/shiove/15669581.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 对数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/shiyigela/.keep b/codes/shiyigela/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/shiyigela/15758629.java b/codes/shiyigela/15758629.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/shiyigela/15758629.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/shongz/15517802.java b/codes/shongz/15517802.java new file mode 100644 index 0000000000000000000000000000000000000000..e98e6cc642a4d33b49c5cde320e32cb7a04b26c7 --- /dev/null +++ b/codes/shongz/15517802.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 该函数实现了冒泡排序算法,将数组中的元素按照从小到大的顺序排列 + * @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 - 1 - i; j++) { // 内层循环,用于比较相邻的元素并进行交换 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/shuchaoyang/15534407.java b/codes/shuchaoyang/15534407.java new file mode 100644 index 0000000000000000000000000000000000000000..46e84220af9670a19aeef8ee10bff62342f00281 --- /dev/null +++ b/codes/shuchaoyang/15534407.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end diff --git a/codes/shuyiyi/15683952.java b/codes/shuyiyi/15683952.java new file mode 100644 index 0000000000000000000000000000000000000000..54c5f3869cd16ee9e7c2b77895a39fae63f05dbc --- /dev/null +++ b/codes/shuyiyi/15683952.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy \ No newline at end of file diff --git a/codes/sianjen/10330887.java b/codes/sianjen/10330887.java new file mode 100644 index 0000000000000000000000000000000000000000..efa6ab36f534da0ba9a330a190ed73f88df93254 --- /dev/null +++ b/codes/sianjen/10330887.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0;ia[j+1]){ + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } + +} //end diff --git a/codes/sichen123/15721908.java b/codes/sichen123/15721908.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/sichen123/15721908.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/silverSmith/15774806.java b/codes/silverSmith/15774806.java new file mode 100644 index 0000000000000000000000000000000000000000..7745e0a985929e07369be8492b55233947d78c01 --- /dev/null +++ b/codes/silverSmith/15774806.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较,将较大的元素交换到数组的末尾,经过多轮比较后,整个数组变得有序。 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + // 交换a[j]和a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/siqiwang/.keep b/codes/siqiwang/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/siqiwang/15311318.java b/codes/siqiwang/15311318.java new file mode 100644 index 0000000000000000000000000000000000000000..343fcd48366acf1c442cc3c54da0deb903bde96b --- /dev/null +++ b/codes/siqiwang/15311318.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/sisiya/15723000.java b/codes/sisiya/15723000.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/sisiya/15723000.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/siwuge2/.keep b/codes/siwuge2/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/siwuge2/15720932.java b/codes/siwuge2/15720932.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/siwuge2/15720932.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/sjms1u2n3s4h5/10104996.java b/codes/sjms1u2n3s4h5/10104996.java new file mode 100644 index 0000000000000000000000000000000000000000..ea1a4cbb7b6f40305a958a39f1cc8bd69bcc9f84 --- /dev/null +++ b/codes/sjms1u2n3s4h5/10104996.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp = 0; + for(int i=0; ii; j--) + { + if(a[j] < a[j-1]) + { + temp = a[j]; + a[j] = a[j-1]; + a[j-1] = temp; + } + } + +} //end diff --git a/codes/slamer/11242607.java b/codes/slamer/11242607.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/slamer/11242607.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/smartpulse/.keep b/codes/smartpulse/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/smartpulse/15774449.java b/codes/smartpulse/15774449.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/smartpulse/15774449.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/smcO0O/.java b/codes/smcO0O/.java new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/codes/smcO0O/.java @@ -0,0 +1 @@ + diff --git a/codes/smcO0O/10708545.java b/codes/smcO0O/10708545.java new file mode 100644 index 0000000000000000000000000000000000000000..c105bd77f4de3a8ee4d902249aea4a752ea18656 --- /dev/null +++ b/codes/smcO0O/10708545.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 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 swap = 0; + swap = a[j]; + a[j] = a[j+1]; + a[j+1] = swap; + } + } + } + +} //end diff --git a/codes/smesa6/11229202.java b/codes/smesa6/11229202.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/smesa6/11229202.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/snowfog/11357833.java b/codes/snowfog/11357833.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/snowfog/11357833.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/ssr88888888/10999180.java b/codes/ssr88888888/10999180.java new file mode 100644 index 0000000000000000000000000000000000000000..607a9246394a817e793043af61e051c104c68f46 --- /dev/null +++ b/codes/ssr88888888/10999180.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end diff --git a/codes/ssya12/15718593.java b/codes/ssya12/15718593.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/ssya12/15718593.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/steven_0324/15724446.java b/codes/steven_0324/15724446.java new file mode 100644 index 0000000000000000000000000000000000000000..23f1972941851fa068cc96dde758fc2decdee46b --- /dev/null +++ b/codes/steven_0324/15724446.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 该函数用于对整数数组进行升序排序 + * @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 diff --git a/codes/stevenchendy/10044195.java b/codes/stevenchendy/10044195.java new file mode 100644 index 0000000000000000000000000000000000000000..3a58202bb9c66c8e83646f483eda20ecd868fe77 --- /dev/null +++ b/codes/stevenchendy/10044195.java @@ -0,0 +1,25 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + + + + + + diff --git a/codes/stevending1st/15193096.java b/codes/stevending1st/15193096.java new file mode 100644 index 0000000000000000000000000000000000000000..79c1730e4ff0c9fad91986d55cf468a66886ddce --- /dev/null +++ b/codes/stevending1st/15193096.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 -1 - i; j++) { + if( a[j] > a[j + 1]) { + int temp = a[j+1]; + a[j+1] = a[j]; + a[j] = temp; + } + } + } +} //end diff --git a/codes/subNvue/11264972.java b/codes/subNvue/11264972.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/subNvue/11264972.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/suixin186/15758969.java b/codes/suixin186/15758969.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b711a46fe664a20752955f5730ee67702ccb8b --- /dev/null +++ b/codes/suixin186/15758969.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int huat = 0; huat < n - i - 1; huat++) { + if(a[huat] > a[huat + 1]) { + int temp = a[huat]; + a [huat] = a[huat + 1]; + a[huat + 1] = temp; + } + } + } + + +} //end,huat diff --git a/codes/sundong/15615609.java b/codes/sundong/15615609.java new file mode 100644 index 0000000000000000000000000000000000000000..d3167e566374947810dbdac59a0170afb6f17e2a --- /dev/null +++ b/codes/sundong/15615609.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较和交换,将较大的元素逐步“浮”到数组的末尾,实现排序。 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + // 当所有轮排序完成后,数组 a 变得有序 +} // end diff --git a/codes/sunjinglei/9956147.java b/codes/sunjinglei/9956147.java new file mode 100644 index 0000000000000000000000000000000000000000..2421b8ea296d1bf6cc7965ff16134efa6b97cb4e --- /dev/null +++ b/codes/sunjinglei/9956147.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-1 - i; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} //end diff --git a/codes/sunxiaoshou/15541950.java b/codes/sunxiaoshou/15541950.java new file mode 100644 index 0000000000000000000000000000000000000000..d6663ea3aec7b12487e70eda00f69b4e138ee78b --- /dev/null +++ b/codes/sunxiaoshou/15541950.java @@ -0,0 +1,12 @@ +public static void bubbleSort(int [] a,int n){ + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +}//end diff --git a/codes/sunys312/10087139.java b/codes/sunys312/10087139.java new file mode 100644 index 0000000000000000000000000000000000000000..0557f90f540f8b0c04fb2072d29b81d24b5942ff --- /dev/null +++ b/codes/sunys312/10087139.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]) { //每次都是和它的下一个元素比 + int t = a[j]; //符合条件则交换 + a[j] = a[j+1]; + a[j+1] = t; + } + } + } + +} //end diff --git a/codes/survivor/15602447.java b/codes/survivor/15602447.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/survivor/15602447.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/sushi13075929819/.keep b/codes/sushi13075929819/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/sushi13075929819/10971905.java b/codes/sushi13075929819/10971905.java new file mode 100644 index 0000000000000000000000000000000000000000..021bb4e4536312340c366b2810e04b694ed73130 --- /dev/null +++ b/codes/sushi13075929819/10971905.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] c, int n) { + for (int i=0 ; ic[j+1]) { + int temp=c[j]; + c[j]=c[j+1]; + c[j+1]=temp; + } + } + } +} diff --git a/codes/susuplus/11211308.java b/codes/susuplus/11211308.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/susuplus/11211308.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/sususu/11260612.java b/codes/sususu/11260612.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/sususu/11260612.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/swgger/11211222.java b/codes/swgger/11211222.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/swgger/11211222.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/syst1m/15514292.java b/codes/syst1m/15514292.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/syst1m/15514292.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/tangda/.keep b/codes/tangda/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/tangda/15764487.java b/codes/tangda/15764487.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/tangda/15764487.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/tangmingqing1998/11752180.java b/codes/tangmingqing1998/11752180.java new file mode 100644 index 0000000000000000000000000000000000000000..c732e78f8d4d6ff439c2083fecaaf3b12ef72dd4 --- /dev/null +++ b/codes/tangmingqing1998/11752180.java @@ -0,0 +1,13 @@ +public static void bubbleSort(int[] arr, int n) { + // 冒泡排序 + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/taoz123/15720694.java b/codes/taoz123/15720694.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/taoz123/15720694.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/tdnginx/11207793.java b/codes/tdnginx/11207793.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/tdnginx/11207793.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/techstars/.keep b/codes/techstars/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/techstars/15774401.java b/codes/techstars/15774401.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/techstars/15774401.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/template/11204937.java b/codes/template/11204937.java new file mode 100644 index 0000000000000000000000000000000000000000..03e2ce1ac322f11189075c78e3073f785dc5a0fd --- /dev/null +++ b/codes/template/11204937.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 diff --git a/codes/tender/15568442.java b/codes/tender/15568442.java new file mode 100644 index 0000000000000000000000000000000000000000..233ced8b3bc1576c50c75a5b08217cf01201a693 --- /dev/null +++ b/codes/tender/15568442.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * 通过重复地遍历要排序的数组,比较每对相邻的元素,并在必要时交换它们的位置, + * 遍历数组的工作是重复地进行直到没有再需要交换,也就是说该数组已经排序完成。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 创建一个标志位,用于检测这一趟是否有交换过 + boolean swapped = false; + for (int j = 0; j < n - i - 1; j++) { + // 如果当前元素大于下一个元素,则交换它们 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + // 标志位设为 true,表示这一趟发生了交换 + swapped = true; + } + } + // 如果这一趟没有发生交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/tfboy168/11207647.java b/codes/tfboy168/11207647.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/tfboy168/11207647.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/theSeven/15555656.java b/codes/theSeven/15555656.java new file mode 100644 index 0000000000000000000000000000000000000000..aca9c89d081ebdaa9c91e4c35a5ecdc9f2215aab --- /dev/null +++ b/codes/theSeven/15555656.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + +} //end diff --git a/codes/thisisanuo/15720471.java b/codes/thisisanuo/15720471.java new file mode 100644 index 0000000000000000000000000000000000000000..3ca4ca932763a4c4917007b3836868da1ce6fac8 --- /dev/null +++ b/codes/thisisanuo/15720471.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 功能:对数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/thisisericq/15715035.java b/codes/thisisericq/15715035.java new file mode 100644 index 0000000000000000000000000000000000000000..79d173396fe87eb976257bce169471d147dc1314 --- /dev/null +++ b/codes/thisisericq/15715035.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较并交换位置,使较大的元素逐渐“浮”到数组的末尾,从而实现排序。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/thisisluosheng/15730125.java b/codes/thisisluosheng/15730125.java new file mode 100644 index 0000000000000000000000000000000000000000..3ca4ca932763a4c4917007b3836868da1ce6fac8 --- /dev/null +++ b/codes/thisisluosheng/15730125.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 功能:对数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/thisislwl/15583856.java b/codes/thisislwl/15583856.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/thisislwl/15583856.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/thisisqlbw/15722233.java b/codes/thisisqlbw/15722233.java new file mode 100644 index 0000000000000000000000000000000000000000..3ca4ca932763a4c4917007b3836868da1ce6fac8 --- /dev/null +++ b/codes/thisisqlbw/15722233.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 功能:对数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/thisissmdmy/15724112.java b/codes/thisissmdmy/15724112.java new file mode 100644 index 0000000000000000000000000000000000000000..3ca4ca932763a4c4917007b3836868da1ce6fac8 --- /dev/null +++ b/codes/thisissmdmy/15724112.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 功能:对数组进行升序排序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/threestones/15517626.java b/codes/threestones/15517626.java new file mode 100644 index 0000000000000000000000000000000000000000..e55c540a4cba34b5207c25070adaa4dfcef3ad1d --- /dev/null +++ b/codes/threestones/15517626.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } +} //end diff --git a/codes/tiandao186/15758999.java b/codes/tiandao186/15758999.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b711a46fe664a20752955f5730ee67702ccb8b --- /dev/null +++ b/codes/tiandao186/15758999.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int huat = 0; huat < n - i - 1; huat++) { + if(a[huat] > a[huat + 1]) { + int temp = a[huat]; + a [huat] = a[huat + 1]; + a[huat + 1] = temp; + } + } + } + + +} //end,huat diff --git a/codes/toutouya/15742811.java b/codes/toutouya/15742811.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/toutouya/15742811.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/tr1120753883/15634698.java b/codes/tr1120753883/15634698.java new file mode 100644 index 0000000000000000000000000000000000000000..6d56cc245b65789ffc55510e1407e393e8fa8a7a --- /dev/null +++ b/codes/tr1120753883/15634698.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int luoluo = 0; luoluo < n - i - 1; luoluo++) { + if(a[luoluo] > a[luoluo + 1]) { + int temp = a[luoluo]; + a [luoluo] = a[luoluo + 1]; + a[luoluo + 1] = temp; + } + } + } + + +} //end,luoluo diff --git a/codes/ttfei123/15719497.java b/codes/ttfei123/15719497.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/ttfei123/15719497.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/ttyylb/11228246.java b/codes/ttyylb/11228246.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/ttyylb/11228246.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/tuboshu/.keep b/codes/tuboshu/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/tuboshu/15767771.java b/codes/tuboshu/15767771.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/tuboshu/15767771.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/tuoera/11301685.java b/codes/tuoera/11301685.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/tuoera/11301685.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/txb0318/.15528488.java.swp b/codes/txb0318/.15528488.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..93fb79d277edf45d1b90460e29ff67fa6bf0d246 Binary files /dev/null and b/codes/txb0318/.15528488.java.swp differ diff --git a/codes/txb0318/15528488.java b/codes/txb0318/15528488.java new file mode 100644 index 0000000000000000000000000000000000000000..b722b465a9a6157557acda313e0d97364276cdf8 --- /dev/null +++ b/codes/txb0318/15528488.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int len = a.length; + for(int i = 0 ; i < len - 1 ; i ++){ + for(int j = 0 ; j < len - 1 - i; j++){ + if(a[j] > a[j + 1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} diff --git a/codes/uacdtsun/11202127.java b/codes/uacdtsun/11202127.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/uacdtsun/11202127.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/uavjuju/10971568.java b/codes/uavjuju/10971568.java new file mode 100644 index 0000000000000000000000000000000000000000..ab3d8f390cfa4cee1947d39872e75bac48b3058a --- /dev/null +++ b/codes/uavjuju/10971568.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/uetvuetv/.keep b/codes/uetvuetv/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/uetvuetv/11207718.java b/codes/uetvuetv/11207718.java new file mode 100644 index 0000000000000000000000000000000000000000..83497d9a50b2195c0f83f28598452b59573c98ad --- /dev/null +++ b/codes/uetvuetv/11207718.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/uioplck/11253331.java b/codes/uioplck/11253331.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/uioplck/11253331.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/uiuiya/15772564.java b/codes/uiuiya/15772564.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/uiuiya/15772564.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/umiapp/11244024.java b/codes/umiapp/11244024.java new file mode 100644 index 0000000000000000000000000000000000000000..7db1ed71c900652c30e8b1c3e9172e685287856a --- /dev/null +++ b/codes/umiapp/11244024.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int []arr, int n) { + 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+1]; + arr[j+1] = arr[j]; + arr[j] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/uniqueO/11369940.java b/codes/uniqueO/11369940.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/uniqueO/11369940.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/upgrade/11267063.java b/codes/upgrade/11267063.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/upgrade/11267063.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/user-2352414618/15578257.java b/codes/user-2352414618/15578257.java new file mode 100644 index 0000000000000000000000000000000000000000..b4a53704066c29418799bf143a2309f0e90fec5a --- /dev/null +++ b/codes/user-2352414618/15578257.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + } + } + } + +} //end diff --git a/codes/user-9548709343/14554338.java b/codes/user-9548709343/14554338.java new file mode 100644 index 0000000000000000000000000000000000000000..0f6d81b71f67894d2dfd50a9b025b2b125e3f367 --- /dev/null +++ b/codes/user-9548709343/14554338.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + + +} //end diff --git a/codes/vanguard/.keep b/codes/vanguard/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/vanguard/15772450.java b/codes/vanguard/15772450.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/vanguard/15772450.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/victory2/15555436.java b/codes/victory2/15555436.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/victory2/15555436.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/viewport/11328946.java b/codes/viewport/11328946.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/viewport/11328946.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/vipsoso/11207552.java b/codes/vipsoso/11207552.java new file mode 100644 index 0000000000000000000000000000000000000000..deb2438785c696d09e985c35997c2f2bc5445a90 --- /dev/null +++ b/codes/vipsoso/11207552.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/vv89889901/11286616.java b/codes/vv89889901/11286616.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/vv89889901/11286616.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/w188555/.keep b/codes/w188555/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/w188555/10043819.java b/codes/w188555/10043819.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/w188555/10043819.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/w964061684/15543696.java b/codes/w964061684/15543696.java new file mode 100644 index 0000000000000000000000000000000000000000..37b075a0be9c25a60677452997e4e67194d3ee9b --- /dev/null +++ b/codes/w964061684/15543696.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 这是一个简单的冒泡排序实现,通过相邻元素之间的比较和交换,将较大的元素逐渐“冒泡”到数组的末尾。 + * @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 diff --git a/codes/wang001/15732362.java b/codes/wang001/15732362.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec373aee12c8b4795c0d670e772620e90ee630e --- /dev/null +++ b/codes/wang001/15732362.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/wangeditor/11461619.java b/codes/wangeditor/11461619.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/wangeditor/11461619.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/wangjz18551603897/9965927.java b/codes/wangjz18551603897/9965927.java new file mode 100644 index 0000000000000000000000000000000000000000..16bc25dc40a1438270d0545a3b4461f5666ddf96 --- /dev/null +++ b/codes/wangjz18551603897/9965927.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp;//定义一个临时变量 + for(int i=0;i a[j + 1]) { + int temp = a[j]; + a [j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + + +} //end \ No newline at end of file diff --git a/codes/wangliping111/15556238.java b/codes/wangliping111/15556238.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/wangliping111/15556238.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/wanglumin/15110274.java b/codes/wanglumin/15110274.java new file mode 100644 index 0000000000000000000000000000000000000000..5f207500d6a828838d90238c3e56435882f6e210 --- /dev/null +++ b/codes/wanglumin/15110274.java @@ -0,0 +1,13 @@ +public static void bubbleSort(int [] a,int n){ + + 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; + } + } + } +} diff --git a/codes/wangsheng112/.keep b/codes/wangsheng112/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/wangsheng112/15741948.java b/codes/wangsheng112/15741948.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/wangsheng112/15741948.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/wangth/12284554.java b/codes/wangth/12284554.java new file mode 100644 index 0000000000000000000000000000000000000000..f4fc0654debe582b6b04dd007fb92d8c7de1ecdb --- /dev/null +++ b/codes/wangth/12284554.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + if (j < n-1 && a[j] > a[j+1]) { + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} diff --git a/codes/wanmeijuhao/15724276.java b/codes/wanmeijuhao/15724276.java new file mode 100644 index 0000000000000000000000000000000000000000..44f7cc659a02fe8bcf8c0e9f02334fe2a6a9ff87 --- /dev/null +++ b/codes/wanmeijuhao/15724276.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * 将无序数组通过冒泡排序算法变为有序数组 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 设置一个标志位,用于优化算法,减少不必要的比较 + boolean swapped = false; + 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; + // 如果有元素交换,则标志位设为true + swapped = true; + } + } + // 如果没有元素交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/waste985/15615158.java b/codes/waste985/15615158.java new file mode 100644 index 0000000000000000000000000000000000000000..53566f4d2876e70f2fa80c1d571a7a778ade860c --- /dev/null +++ b/codes/waste985/15615158.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 通过相邻元素两两比较并交换,将较大的元素逐渐交换到数组的末尾,达到排序的目的。 + * @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 - 1 - i; j++) { // 内层循环,从前往后比较相邻元素 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/waterdrop/15514437.java b/codes/waterdrop/15514437.java new file mode 100644 index 0000000000000000000000000000000000000000..91b9a83d57ddf638ec0451596dd95402b887f1fc --- /dev/null +++ b/codes/waterdrop/15514437.java @@ -0,0 +1,26 @@ +/** + * 冒泡排序函数 + * 对数组a进行升序排序 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 设置一个标志位,表示本趟是否有交换 + boolean swapped = false; + 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; + // 表示本趟发生了交换 + swapped = true; + } + } + // 如果本趟没有发生交换,说明数组已经有序,可以提前结束 + if (!swapped) { + break; + } + } +} // end diff --git a/codes/waveriders/.keep b/codes/waveriders/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/waveriders/15772349.java b/codes/waveriders/15772349.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/waveriders/15772349.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/wcc0066/11473178.java b/codes/wcc0066/11473178.java new file mode 100644 index 0000000000000000000000000000000000000000..8c505501c812f686a9abe78a0d1191db6085134c --- /dev/null +++ b/codes/wcc0066/11473178.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/wcjm2023/11233911.java b/codes/wcjm2023/11233911.java new file mode 100644 index 0000000000000000000000000000000000000000..029e9d84c1474520908887693e69aabcb7ff0aba --- /dev/null +++ b/codes/wcjm2023/11233911.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 +*/ +public static void bubbleSort(int [] a, int n){ + int j , k; + int flag = n ;//flag来记录最后交换的位置,也就是排序的尾边界 + + while (flag > 0){//排序未结束标志 + k = flag; //k 来记录遍历的尾边界 + flag = 0; + + for(j=1; j a[j]){//前面的数字大于后面的数字就交换 + //交换a[j-1]和a[j] + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j]=temp; + + //表示交换过数据; + flag = j;//记录最新的尾边界. + } + } + } +} \ No newline at end of file diff --git a/codes/wdg1994/15654397.java b/codes/wdg1994/15654397.java new file mode 100644 index 0000000000000000000000000000000000000000..9a7a71cd52191bcff90e688901904eb1a85cc943 --- /dev/null +++ b/codes/wdg1994/15654397.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 冒泡排序是一种简单的排序算法,它重复地遍历要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 + * 遍历数列的工作是重复地进行直到没有再需要交换,也就是说该数列已经排序完成。 + * @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 diff --git a/codes/wdnmd123/10967263.java b/codes/wdnmd123/10967263.java new file mode 100644 index 0000000000000000000000000000000000000000..029e9d84c1474520908887693e69aabcb7ff0aba --- /dev/null +++ b/codes/wdnmd123/10967263.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 +*/ +public static void bubbleSort(int [] a, int n){ + int j , k; + int flag = n ;//flag来记录最后交换的位置,也就是排序的尾边界 + + while (flag > 0){//排序未结束标志 + k = flag; //k 来记录遍历的尾边界 + flag = 0; + + for(j=1; j a[j]){//前面的数字大于后面的数字就交换 + //交换a[j-1]和a[j] + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j]=temp; + + //表示交换过数据; + flag = j;//记录最新的尾边界. + } + } + } +} \ No newline at end of file diff --git a/codes/web3dapp/10996679.java b/codes/web3dapp/10996679.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/web3dapp/10996679.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/webAssembly/11131659.java b/codes/webAssembly/11131659.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/webAssembly/11131659.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/wechat/11212111.java b/codes/wechat/11212111.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/wechat/11212111.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/weiha162/15759131.java b/codes/weiha162/15759131.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/weiha162/15759131.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/weisss/15526691.java b/codes/weisss/15526691.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/weisss/15526691.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/weiwenjie/15736197.java b/codes/weiwenjie/15736197.java new file mode 100644 index 0000000000000000000000000000000000000000..363fb48393436081f17448f6c0435527a9086619 --- /dev/null +++ b/codes/weiwenjie/15736197.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/weiyanqiu/15624187.java b/codes/weiyanqiu/15624187.java new file mode 100644 index 0000000000000000000000000000000000000000..2252b818e6125ed4f8bbd23eca03c12c15ca1757 --- /dev/null +++ b/codes/weiyanqiu/15624187.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/wenhuiyu/.keep b/codes/wenhuiyu/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/wenhuiyu/15765207.java b/codes/wenhuiyu/15765207.java new file mode 100644 index 0000000000000000000000000000000000000000..6426772fb479b07ed3be21ef1867921d1dbb194c --- /dev/null +++ b/codes/wenhuiyu/15765207.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; 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 \ No newline at end of file diff --git a/codes/whc666/15671266.java b/codes/whc666/15671266.java new file mode 100644 index 0000000000000000000000000000000000000000..ff7eca84596587eab6d25e207c2cf25b1d158493 --- /dev/null +++ b/codes/whc666/15671266.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 这是一个简单的排序算法,通过重复地遍历要排序的数组, + * 比较每对相邻的项,如果它们的顺序错误就把它们交换过来。 + * @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 diff --git a/codes/wingwf/15632876.java b/codes/wingwf/15632876.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/wingwf/15632876.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/witty1972/10970403.java b/codes/witty1972/10970403.java new file mode 100644 index 0000000000000000000000000000000000000000..17fef721530efd49f410412d6cacc6ede8e756c3 --- /dev/null +++ b/codes/witty1972/10970403.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param l 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int l){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/wjhh111/15628801.java b/codes/wjhh111/15628801.java new file mode 100644 index 0000000000000000000000000000000000000000..04625a494ce3da760397a3c3c648cdbe5d0bfa71 --- /dev/null +++ b/codes/wjhh111/15628801.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end + diff --git a/codes/wjy030522/15582699.java b/codes/wjy030522/15582699.java new file mode 100644 index 0000000000000000000000000000000000000000..23d208a4b8fdb0880b8baebff2ba2d52ee013b81 --- /dev/null +++ b/codes/wjy030522/15582699.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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]) { + // 交换a[j]和a[j+1]的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/wll123/10971000.java b/codes/wll123/10971000.java new file mode 100644 index 0000000000000000000000000000000000000000..67a97db0f2fbb50ee06aa49da443c533d4552bcd --- /dev/null +++ b/codes/wll123/10971000.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { +for (int i=0 ; ia[wll+1]) { +int temp=a[wll]; +a[wll]=a[wll+1]; +a[wll+1]=temp; +} +} +} +} diff --git a/codes/wll123/15541001.java b/codes/wll123/15541001.java new file mode 100644 index 0000000000000000000000000000000000000000..324687283489419c5a6916c234a8848f65a5eb64 --- /dev/null +++ b/codes/wll123/15541001.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int tata = 0; tata < n - i - 1; tata++) { + if(a[tata] > a[tata + 1]) { + int temp = a[tata]; + a [tata] = a[tata + 1]; + a[tata + 1] = temp; + } + } + } + + +} //end,tatazj diff --git a/codes/wmmnmd/11212424.java b/codes/wmmnmd/11212424.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/wmmnmd/11212424.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/wq456wrfs/.keep b/codes/wq456wrfs/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/wq456wrfs/15743473.java b/codes/wq456wrfs/15743473.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/wq456wrfs/15743473.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/wtfock/11212229.java b/codes/wtfock/11212229.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/wtfock/11212229.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/wu123-/15587168.java b/codes/wu123-/15587168.java new file mode 100644 index 0000000000000000000000000000000000000000..2252b818e6125ed4f8bbd23eca03c12c15ca1757 --- /dev/null +++ b/codes/wu123-/15587168.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/wu13935784487/15636076.java b/codes/wu13935784487/15636076.java new file mode 100644 index 0000000000000000000000000000000000000000..ba384e282a3ba1793fc7e59e40f742a9480a720f --- /dev/null +++ b/codes/wu13935784487/15636076.java @@ -0,0 +1,20 @@ + +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end + diff --git a/codes/wu616562636/9947556.java b/codes/wu616562636/9947556.java new file mode 100644 index 0000000000000000000000000000000000000000..835733e94dbc37ec9aa5b27d7f0347bb78d3ff13 --- /dev/null +++ b/codes/wu616562636/9947556.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end diff --git a/codes/wuDaoya/11122066.java b/codes/wuDaoya/11122066.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/wuDaoya/11122066.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/wucga1/11179945.java b/codes/wucga1/11179945.java new file mode 100644 index 0000000000000000000000000000000000000000..cdabc2e0876ad629e41ff055727cf3af34be8917 --- /dev/null +++ b/codes/wucga1/11179945.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int temp = a[j]; + a[j] = a[i]; + a[i] = temp; + + } + } + } + +} //end \ No newline at end of file diff --git a/codes/wulibaibao/9691535.java b/codes/wulibaibao/9691535.java new file mode 100644 index 0000000000000000000000000000000000000000..d26e4c63f0ff629f116c8f9c7a0f50d886c1a085 --- /dev/null +++ b/codes/wulibaibao/9691535.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp;//定义一个临时变量 + for(int i=0;i a[j + 1]) { + int temp = a[j]; + a [j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + + +} //end \ No newline at end of file diff --git a/codes/wupengyu/10969882.java b/codes/wupengyu/10969882.java new file mode 100644 index 0000000000000000000000000000000000000000..e8c00623e1098f480046be18e2267f3209083664 --- /dev/null +++ b/codes/wupengyu/10969882.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[k+1]) { + int temp=a[k]; + a[k]=a[k+1]; + a[k+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/wuzhenzi001/15711848.java b/codes/wuzhenzi001/15711848.java new file mode 100644 index 0000000000000000000000000000000000000000..b716c78c830b4135702410111305f4c87192e989 --- /dev/null +++ b/codes/wuzhenzi001/15711848.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { // 外层循环,控制排序的轮数 + // i 表示当前已经排序好的元素个数,因此每一轮排序后,最大的元素会移到正确的位置 + for (int j = 0; j < n - i - 1; j++) { // 内层循环,控制每轮中比较的次数 + // j 表示当前比较的元素索引,从0开始到n-i-2,因为最后i个元素已经是排序好的 + if (a[j] > a[j + 1]) { // 如果当前元素大于下一个元素 + // 则交换这两个元素的位置,保证较大的元素向数组的末尾移动 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; // 使用临时变量temp存储a[j]的值 + a[j] = a[j + 1]; // 将a[j+1]的值赋给a[j] + a[j + 1] = temp; // 将temp(即原来的a[j]的值)赋给a[j+1] + } + } + } +} diff --git a/codes/wwee123/15720571.java b/codes/wwee123/15720571.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/wwee123/15720571.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/wwh1096046571/.keep b/codes/wwh1096046571/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/wwh1096046571/10040814.java b/codes/wwh1096046571/10040814.java new file mode 100644 index 0000000000000000000000000000000000000000..29d27043d3c8103739e7a1d2a27e77b4cc475876 --- /dev/null +++ b/codes/wwh1096046571/10040814.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 diff --git a/codes/wws001227/15774783.java b/codes/wws001227/15774783.java new file mode 100644 index 0000000000000000000000000000000000000000..4d9a324f5ba71d51fe6bce087bee818971b65d57 --- /dev/null +++ b/codes/wws001227/15774783.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 通过不断比较相邻元素,并交换位置(如果前一个元素大于后一个元素),将最大元素逐渐“浮”到数组的末尾, + * 重复这个过程直到整个数组有序。 + * @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 - 1 - i; j++) { // 内层循环,进行相邻元素的比较和交换 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素 + // 交换位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/wxf68725032/10117253.java b/codes/wxf68725032/10117253.java new file mode 100644 index 0000000000000000000000000000000000000000..b80bde062ebabb5b4152ce6521bd5adbcef89438 --- /dev/null +++ b/codes/wxf68725032/10117253.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} diff --git a/codes/wxyaya/15684359.java b/codes/wxyaya/15684359.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/wxyaya/15684359.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/wy16651754941/.keep b/codes/wy16651754941/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/wy16651754941/10972345.java b/codes/wy16651754941/10972345.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/wy16651754941/10972345.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/wyk12345/9950042.java b/codes/wyk12345/9950042.java new file mode 100644 index 0000000000000000000000000000000000000000..e7e148134fc132dad44ff7afe942282adb454145 --- /dev/null +++ b/codes/wyk12345/9950042.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j]>a[j+1]) { + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/wzj123/15628771.java b/codes/wzj123/15628771.java new file mode 100644 index 0000000000000000000000000000000000000000..4127ce2b2a03df3241338ff0d58963e659bf7652 --- /dev/null +++ b/codes/wzj123/15628771.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int wzj = 0; wzj < n - i - 1; wzj++) { + if(a[wzj] > a[wzj + 1]) { + int temp = a[wzj]; + a [wzj] = a[wzj + 1]; + a[wzj + 1] = temp; + } + } + } + + +} //end,wzj diff --git a/codes/x123456/10987993.java b/codes/x123456/10987993.java new file mode 100644 index 0000000000000000000000000000000000000000..5734db7cf39e899889811c1565df67b4313f5b3a --- /dev/null +++ b/codes/x123456/10987993.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { +for (int i=0 ; ia[xiangxixi+1]) { +int temp=a[xiangxixi]; +a[xiangxixi]=a[xiangxixi+1]; +a[xiangxixi+1]=temp; +} +} +} +} diff --git a/codes/x123456/15539350.java b/codes/x123456/15539350.java new file mode 100644 index 0000000000000000000000000000000000000000..05f4af4cc82e38626109fbe95ac0ee530c079fa7 --- /dev/null +++ b/codes/x123456/15539350.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int xixi = 0; xixi < n - i - 1; xixi++) { + if(a[xixi] > a[xixi + 1]) { + int temp = a[xixi]; + a [xixi] = a[xixi + 1]; + a[xixi + 1] = temp; + } + } + } + + +} //end,240316 diff --git a/codes/xaioli/15562718.java b/codes/xaioli/15562718.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/xaioli/15562718.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/xcw18988783240/.keep b/codes/xcw18988783240/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/xcw18988783240/10972415.java b/codes/xcw18988783240/10972415.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/xcw18988783240/10972415.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/xd16750866428/.keep b/codes/xd16750866428/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/xd16750866428/10972670.java b/codes/xd16750866428/10972670.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/xd16750866428/10972670.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/xhm17860971687/.keep b/codes/xhm17860971687/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/xhm17860971687/10043024.java b/codes/xhm17860971687/10043024.java new file mode 100644 index 0000000000000000000000000000000000000000..667eee0f585ec38ce639cb36d80df080e935946d --- /dev/null +++ b/codes/xhm17860971687/10043024.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/xi13313987553/.keep b/codes/xi13313987553/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/xi13313987553/10972326.java b/codes/xi13313987553/10972326.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/xi13313987553/10972326.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/xiao555/.java.swp b/codes/xiao555/.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..795788efc79a796adfe4f73a643c3ca4c175dbd3 Binary files /dev/null and b/codes/xiao555/.java.swp differ diff --git a/codes/xiao555/15576144.java b/codes/xiao555/15576144.java new file mode 100644 index 0000000000000000000000000000000000000000..d37655e03d86725efd557432545637d3ab3e021b --- /dev/null +++ b/codes/xiao555/15576144.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/xiaoai/15563405.java b/codes/xiaoai/15563405.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/xiaoai/15563405.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/xiaoduo/15742206.java b/codes/xiaoduo/15742206.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xiaoduo/15742206.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xiaoer1/15626743.java b/codes/xiaoer1/15626743.java new file mode 100644 index 0000000000000000000000000000000000000000..ba0c7823c8c801b5bd59ec7814d26f2828d9f8bf --- /dev/null +++ b/codes/xiaoer1/15626743.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 冒泡排序是一种简单的排序算法,它重复地遍历要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 + * @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 - 1 - i; j++) { // 内层循环控制每一轮的比较次数 + if (a[j] > a[j + 1]) { // 如果前一个元素大于后一个元素,则交换它们的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/xiaohanhan/15743008.java b/codes/xiaohanhan/15743008.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b711a46fe664a20752955f5730ee67702ccb8b --- /dev/null +++ b/codes/xiaohanhan/15743008.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int huat = 0; huat < n - i - 1; huat++) { + if(a[huat] > a[huat + 1]) { + int temp = a[huat]; + a [huat] = a[huat + 1]; + a[huat + 1] = temp; + } + } + } + + +} //end,huat diff --git a/codes/xiaohuaya/15742515.java b/codes/xiaohuaya/15742515.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xiaohuaya/15742515.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xiaohudui/15724769.java b/codes/xiaohudui/15724769.java new file mode 100644 index 0000000000000000000000000000000000000000..d612a9d6324e9ddde1fce6ccb74b38a12b4e973d --- /dev/null +++ b/codes/xiaohudui/15724769.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * 将无序数组通过冒泡排序算法变为有序数组 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 设置一个标志位,用于优化算法,减少不必要的比较 + boolean swapped = false; + 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; + // 如果有元素交换,则标志位设为true + swapped = true; + } + } + // 如果没有元素交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end + diff --git a/codes/xiaohudui/:wqwq b/codes/xiaohudui/:wqwq new file mode 100644 index 0000000000000000000000000000000000000000..d612a9d6324e9ddde1fce6ccb74b38a12b4e973d --- /dev/null +++ b/codes/xiaohudui/:wqwq @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * 将无序数组通过冒泡排序算法变为有序数组 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 设置一个标志位,用于优化算法,减少不必要的比较 + boolean swapped = false; + 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; + // 如果有元素交换,则标志位设为true + swapped = true; + } + } + // 如果没有元素交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end + diff --git a/codes/xiaomi167/15759142.java b/codes/xiaomi167/15759142.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/xiaomi167/15759142.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/xiaosheng333/15692737.java b/codes/xiaosheng333/15692737.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/xiaosheng333/15692737.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/xiaowang818/15651046.java b/codes/xiaowang818/15651046.java new file mode 100644 index 0000000000000000000000000000000000000000..efccdd392a01ad6c4c94f113aeea500c9578d82e --- /dev/null +++ b/codes/xiaowang818/15651046.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 0; j < n - i - 1; ++j) { + if(a[j] > a[j + 1]) { + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end diff --git a/codes/xiaowuya/15742288.java b/codes/xiaowuya/15742288.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xiaowuya/15742288.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xiaoxiaoya/15742403.java b/codes/xiaoxiaoya/15742403.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xiaoxiaoya/15742403.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xiaoxuzhu/15488956.java b/codes/xiaoxuzhu/15488956.java new file mode 100644 index 0000000000000000000000000000000000000000..859dc35ff6dd4e7a1e3ee1d12b3ff66a1622cffa --- /dev/null +++ b/codes/xiaoxuzhu/15488956.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * 将数组a从小到大进行排序 + * @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 diff --git a/codes/xiaoyiyi/15742502.java b/codes/xiaoyiyi/15742502.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xiaoyiyi/15742502.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xie-yuxuan44/13983623.java b/codes/xie-yuxuan44/13983623.java new file mode 100644 index 0000000000000000000000000000000000000000..9eafb6af9e0be9cdcf5dd36e00179503aa43d622 --- /dev/null +++ b/codes/xie-yuxuan44/13983623.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + +public static void bubbleSort(int [] a, int n) { + for (int i = n; i > 1; --i) { + for (int j = 1; j < i; ++j) { + if (a[j] < a[j-1]) { + final int temp = a[j]; + a[j] = a[j-1]; + a[j-1] = temp; + } + } + } +} // end diff --git a/codes/xierya/15742677.java b/codes/xierya/15742677.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xierya/15742677.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xieyiyi/9964192.java b/codes/xieyiyi/9964192.java new file mode 100644 index 0000000000000000000000000000000000000000..82b73c8ff8181a822b4e5b9b4a74866761c7b1ca --- /dev/null +++ b/codes/xieyiyi/9964192.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end + diff --git a/codes/xileya/15685017.java b/codes/xileya/15685017.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xileya/15685017.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xingwang/11302451.java b/codes/xingwang/11302451.java new file mode 100644 index 0000000000000000000000000000000000000000..4d7083fe05ce3e6d3fadd59d6d55e2cbc50d546d --- /dev/null +++ b/codes/xingwang/11302451.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i, j; + + for(i=0; ia[j]){ + int temp; + temp = a[j-1]; + a[j-1] = a[j]; + a[j] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/xingya6/15700119.java b/codes/xingya6/15700119.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xingya6/15700119.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xinsui/15719607.java b/codes/xinsui/15719607.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xinsui/15719607.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xinyuxu/.keep b/codes/xinyuxu/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/xinyuxu/10987804.java b/codes/xinyuxu/10987804.java new file mode 100644 index 0000000000000000000000000000000000000000..9f86eb587f5fb5dee2fac7e589a1cf95128af5cc --- /dev/null +++ b/codes/xinyuxu/10987804.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/xizhiya/15699232.java b/codes/xizhiya/15699232.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/xizhiya/15699232.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/xjz21571/15614490.java b/codes/xjz21571/15614490.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/xjz21571/15614490.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/xmicai/15738579.java b/codes/xmicai/15738579.java new file mode 100644 index 0000000000000000000000000000000000000000..88eab86fcf3ff7a2a506375d0a2871beb91f7efa --- /dev/null +++ b/codes/xmicai/15738579.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 将数组a按照升序排列 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + // 遍历所有数组元素 + for (int i = 0; i < n - 1; i++) { + // 最后i个元素已经有序,无需再次比较 + for (int j = 0; j < n - i - 1; j++) { + // 如果当前元素大于下一个元素,则交换它们 + if (a[j] > a[j + 1]) { + // 交换a[j]和a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/xuanxuan/15630222.java b/codes/xuanxuan/15630222.java new file mode 100644 index 0000000000000000000000000000000000000000..efccdd392a01ad6c4c94f113aeea500c9578d82e --- /dev/null +++ b/codes/xuanxuan/15630222.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int j = 0; j < n - i - 1; ++j) { + if(a[j] > a[j + 1]) { + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } +} //end diff --git a/codes/xujinxin001/9946130.java b/codes/xujinxin001/9946130.java new file mode 100644 index 0000000000000000000000000000000000000000..3cdfa33473226465eaa7598d69b9455471bdde9d --- /dev/null +++ b/codes/xujinxin001/9946130.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + //变量 + int template = 0; // 交换变量 + + for(int i = 0; i < n-1; i++){ + for(int j = 0;j < n-1-i; j ++){ + if(a[j] > a[j+1]){ + template = a[j]; + a[j] = a[j+1]; + a[j+1] = template; + } + } + } + +} //end diff --git a/codes/xuliang/.keep b/codes/xuliang/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/xuliang/10045776.java b/codes/xuliang/10045776.java new file mode 100644 index 0000000000000000000000000000000000000000..a5f94c2c491fa5d0e9f0398e1fb8a26dc95010cc --- /dev/null +++ b/codes/xuliang/10045776.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/xunnan/15643977.java b/codes/xunnan/15643977.java new file mode 100644 index 0000000000000000000000000000000000000000..9c2bfde6d890a7a1fe291253ded7aead2baaf7d9 --- /dev/null +++ b/codes/xunnan/15643977.java @@ -0,0 +1,30 @@ +/** + * 冒泡排序函数 + * 通过多次遍历数组,相邻元素两两比较并交换,使得较大的元素逐渐"浮"到数组的末尾, + * 从而实现数组的升序排序。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 用于标记数组在本次遍历中是否发生了交换 + boolean swapped = false; + + 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; + // 标记发生了交换 + swapped = true; + } + } + + // 如果本次遍历中没有发生交换,说明数组已经有序,无需继续遍历 + if (!swapped) { + break; + } + } +} //end + diff --git a/codes/xuwangcheng14/10934340.java b/codes/xuwangcheng14/10934340.java new file mode 100644 index 0000000000000000000000000000000000000000..19321a0e6339c131767967fb046d5192f5b85f9e --- /dev/null +++ b/codes/xuwangcheng14/10934340.java @@ -0,0 +1,22 @@ +/** +* 冒泡排序函数 +* 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 - i - 1;j++) { + if (a[j] > a[j + 1]) { + int temp1 = a[j]; + int temp2 = a[j + 1]; + a[j] = temp2; + a[j + 1] = temp1; + } + } + } + for (int m:a) { + System.out.println(m); + } +} //end diff --git a/codes/xuxidong/15575339.java b/codes/xuxidong/15575339.java new file mode 100644 index 0000000000000000000000000000000000000000..e61a643c07876f5e9d3301469f4e0c6764b06d0c --- /dev/null +++ b/codes/xuxidong/15575339.java @@ -0,0 +1,17 @@ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n - 1; i++) { + boolean swapped = false; + 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; + swapped = true; + } + } + if (!swapped) { + break; + } + } +} //end diff --git a/codes/xxii77/15720091.java b/codes/xxii77/15720091.java new file mode 100644 index 0000000000000000000000000000000000000000..ee789390d77e3ded64de29a5b90b815520b655d0 --- /dev/null +++ b/codes/xxii77/15720091.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * 对数组进行升序排序 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 标志位,表示这一趟排序是否有数据交换 + boolean swapped = false; + for (int j = 0; j < n - i - 1; j++) { + // 如果当前元素大于下一个元素,则交换它们 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + // 表示有数据交换,需要继续下一趟排序 + swapped = true; + } + } + // 如果在内层循环中没有数据交换,则说明数组已经有序,可以提前退出 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/xxy88888888/11073406.java b/codes/xxy88888888/11073406.java new file mode 100644 index 0000000000000000000000000000000000000000..661499fc3a69b869708e75b839ddbc12a2776d9b --- /dev/null +++ b/codes/xxy88888888/11073406.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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} diff --git a/codes/xymdaysgone/15343399.java b/codes/xymdaysgone/15343399.java new file mode 100644 index 0000000000000000000000000000000000000000..25d6275da63650c3c0ebfe1933e6be3931e0c5bd --- /dev/null +++ b/codes/xymdaysgone/15343399.java @@ -0,0 +1,13 @@ +public static void bubbleSort(int[] arr, int n) { + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - i - 1; j++) { + if (arr[j] > arr[j + 1]) { + // Swap arr[j] and arr[j + 1] + int temp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = temp; + } + } + } +} + diff --git a/codes/xzl999/11211117.java b/codes/xzl999/11211117.java new file mode 100644 index 0000000000000000000000000000000000000000..7db1ed71c900652c30e8b1c3e9172e685287856a --- /dev/null +++ b/codes/xzl999/11211117.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int []arr, int n) { + 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+1]; + arr[j+1] = arr[j]; + arr[j] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/y18352279320/.keep b/codes/y18352279320/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/y18352279320/10972594.java b/codes/y18352279320/10972594.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/y18352279320/10972594.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/y80730176/15381500.java b/codes/y80730176/15381500.java new file mode 100644 index 0000000000000000000000000000000000000000..12567aa3d15c1b291b6022b02749ba2904d98578 --- /dev/null +++ b/codes/y80730176/15381500.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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; ja[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] =temp; + } + } + } + } //end diff --git a/codes/yai214/11079560.java b/codes/yai214/11079560.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/yai214/11079560.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/codes/yalou1/11209005.java b/codes/yalou1/11209005.java new file mode 100644 index 0000000000000000000000000000000000000000..8d589d7edfe50246fe5deff283186d81a64dc137 --- /dev/null +++ b/codes/yalou1/11209005.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a,int n){ + int temp =0; + for(int i = 0;ia[j+1]){ + temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + + + +} \ No newline at end of file diff --git a/codes/yanerya/15771918.java b/codes/yanerya/15771918.java new file mode 100644 index 0000000000000000000000000000000000000000..f2b711a46fe664a20752955f5730ee67702ccb8b --- /dev/null +++ b/codes/yanerya/15771918.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int huat = 0; huat < n - i - 1; huat++) { + if(a[huat] > a[huat + 1]) { + int temp = a[huat]; + a [huat] = a[huat + 1]; + a[huat + 1] = temp; + } + } + } + + +} //end,huat diff --git a/codes/yang123456/15540673.java b/codes/yang123456/15540673.java new file mode 100644 index 0000000000000000000000000000000000000000..b56a064e731b75bc4d4bb6a3b539d212cbce615d --- /dev/null +++ b/codes/yang123456/15540673.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 通过相邻元素之间的比较和交换,将较大的元素逐渐“浮”到数组的末尾,从而完成排序 + * @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 - 1 - i; j++) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + // 排序结束,数组a现在是有序的 +} //end + diff --git a/codes/yangqing/9755006.java b/codes/yangqing/9755006.java new file mode 100644 index 0000000000000000000000000000000000000000..59082f65cbbe8c6b6acbf7f8f28a3129c55a220a --- /dev/null +++ b/codes/yangqing/9755006.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + n=a[j]; + a[j]=a[j+1]; + a[j+1]=n; + } + } + } + for(int i=0;i a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } +} \ No newline at end of file diff --git a/codes/yangyang167/15759151.java b/codes/yangyang167/15759151.java new file mode 100644 index 0000000000000000000000000000000000000000..76cbddd876f8669466e0a2651682cee667741713 --- /dev/null +++ b/codes/yangyang167/15759151.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int b = 0; b < n - i - 1; b++) { + if(a[b] > a[b + 1]) { + int temp = a[b]; + a [b] = a[b + 1]; + a[b + 1] = temp; + } + } + } + + +} //end diff --git a/codes/yanson/15355616.java b/codes/yanson/15355616.java new file mode 100644 index 0000000000000000000000000000000000000000..53aa2f8b5d03917f22e07eb72085567cfa46841e --- /dev/null +++ b/codes/yanson/15355616.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +} diff --git a/codes/yanyan123/15721395.java b/codes/yanyan123/15721395.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/yanyan123/15721395.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/yanzi666/15636134.java b/codes/yanzi666/15636134.java new file mode 100644 index 0000000000000000000000000000000000000000..2faa89c72d8e17a7cae501d172d9762995988d17 --- /dev/null +++ b/codes/yanzi666/15636134.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 该函数会对输入的数组进行升序排序 + * @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 - 1 - i; j++) { // 内层循环控制每一趟的排序过程 + if (a[j] > a[j + 1]) { // 如果当前元素大于下一个元素,则交换它们的位置 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/yeats_liao/.keep b/codes/yeats_liao/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/yeats_liao/9946775.java b/codes/yeats_liao/9946775.java new file mode 100644 index 0000000000000000000000000000000000000000..408e7021b7c91a3e0806901aa30f7b99f287ac3e --- /dev/null +++ b/codes/yeats_liao/9946775.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end diff --git a/codes/yhfysun/15523539.java b/codes/yhfysun/15523539.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/yhfysun/15523539.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/yiiixxxx/15688342.java b/codes/yiiixxxx/15688342.java new file mode 100644 index 0000000000000000000000000000000000000000..240d048c4f9fe406136ace647eee2cbd7197b2ed --- /dev/null +++ b/codes/yiiixxxx/15688342.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * 依次比较相邻的元素,如果顺序错误则交换它们,直到没有需要交换的元素为止。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + for (int i = 0; i < n - 1; i++) { + // 标记是否有交换,用于优化在某一趟排序中无交换时提前结束 + boolean swapped = false; + for (int j = 0; j < n - i - 1; j++) { + // 如果当前元素大于下一个元素,则交换它们 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + // 标记本趟有交换发生 + swapped = true; + } + } + // 如果某一趟排序中没有发生交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} // end diff --git a/codes/yikanji/10160695.java b/codes/yikanji/10160695.java new file mode 100644 index 0000000000000000000000000000000000000000..bd82b07de14dad4d7c8b6b8bd1e16555dbfb44b5 --- /dev/null +++ b/codes/yikanji/10160695.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = n - 1; j > i; j--) { + if (a[j] < a[j-1]) { + int temp = a[j]; + a[j] = a[j-1]; + a[j-1] = temp; + } + } + } +} //end diff --git a/codes/yinrr123/15627843.java b/codes/yinrr123/15627843.java new file mode 100644 index 0000000000000000000000000000000000000000..f6bba3727ed30eed0810143729439c8b003522b2 --- /dev/null +++ b/codes/yinrr123/15627843.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int yinrr = 0; yinrr < n - i - 1; yinrr++) { + if(a[yinrr] > a[yinrr + 1]) { + int temp = a[yinrr]; + a [yinrr] = a[yinrr + 1]; + a[yinrr + 1] = temp; + } + } + } + + +} //end,yinrrzj diff --git a/codes/yisuiyuan/.java b/codes/yisuiyuan/.java new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/yisuiyuan/15539123.java b/codes/yisuiyuan/15539123.java new file mode 100644 index 0000000000000000000000000000000000000000..65c0185585de579edb6caf41a9f8509595e21046 --- /dev/null +++ b/codes/yisuiyuan/15539123.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换a[j]和a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + } // end diff --git a/codes/yixiak/15186898.java b/codes/yixiak/15186898.java new file mode 100644 index 0000000000000000000000000000000000000000..c53c87605e83bad70d7f5a3ec2b4f3965ca69f9d --- /dev/null +++ b/codes/yixiak/15186898.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = i + 1; j < n; j++) { + if (a[i] > a[j]) { + int tmp = a[j]; + a[j] = a[i]; + a[i] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/yiyi123/15684743.java b/codes/yiyi123/15684743.java new file mode 100644 index 0000000000000000000000000000000000000000..54c5f3869cd16ee9e7c2b77895a39fae63f05dbc --- /dev/null +++ b/codes/yiyi123/15684743.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy \ No newline at end of file diff --git a/codes/yiyicoder/15630262.java b/codes/yiyicoder/15630262.java new file mode 100644 index 0000000000000000000000000000000000000000..9de98c3feda56594aba5c4720c49ec34b7158aa0 --- /dev/null +++ b/codes/yiyicoder/15630262.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 对数组进行冒泡排序,使其变得有序 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/yj1198222879/9947891.java b/codes/yj1198222879/9947891.java new file mode 100644 index 0000000000000000000000000000000000000000..dad23608af8a7494731fa2b37881b8ccd926c8bc --- /dev/null +++ b/codes/yj1198222879/9947891.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int i,j; + for (i=n-1; i>0; i--) { + for (j=0; j a[j+1]) { + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + } + } + } +} //end diff --git a/codes/yjh123456/15542529.java b/codes/yjh123456/15542529.java new file mode 100644 index 0000000000000000000000000000000000000000..1a35e9c62ccaa8e1277e39f70a2a6b18b17b001e --- /dev/null +++ b/codes/yjh123456/15542529.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int xtians = 0; xtians < n - i - 1; xtians++) { + if(a[xtians] > a[xtians + 1]) { + int temp = a[xtians]; + a [xtians] = a[xtians + 1]; + a[xtians + 1] = temp; + } + } + } + + +} //end,ok结束 diff --git a/codes/yk12345/15606552.java b/codes/yk12345/15606552.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/yk12345/15606552.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/ylolpeng/11122754.java b/codes/ylolpeng/11122754.java new file mode 100644 index 0000000000000000000000000000000000000000..a833d8d31b2581029ab106b60f560dd2c73ff238 --- /dev/null +++ b/codes/ylolpeng/11122754.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + //System.out.println(a); + +} //end \ No newline at end of file diff --git a/codes/ymx2026/11211004.java b/codes/ymx2026/11211004.java new file mode 100644 index 0000000000000000000000000000000000000000..153827af839d9541a28ed18f3452d9fe079c6061 --- /dev/null +++ b/codes/ymx2026/11211004.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + int t=a[j]; + a[j]=a[j+1]; + a[j+1]=t; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/yoU_Qu/15526866.java b/codes/yoU_Qu/15526866.java new file mode 100644 index 0000000000000000000000000000000000000000..2f5fcde8f2411450332b695ff18c212024f86b31 --- /dev/null +++ b/codes/yoU_Qu/15526866.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/yrr456/15542411.java b/codes/yrr456/15542411.java new file mode 100644 index 0000000000000000000000000000000000000000..3ea950914ef6ca7a530393ef2ca61c960b899923 --- /dev/null +++ b/codes/yrr456/15542411.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int ruirui = 0; ruirui < n - i - 1; ruirui++) { + if(a[ruirui] > a[ruirui + 1]) { + int temp = a[ruirui]; + a [ruirui] = a[ruirui + 1]; + a[ruirui + 1] = temp; + } + } + } + + +} //end,ruirui diff --git a/codes/ysyhl9tian/15698870.java b/codes/ysyhl9tian/15698870.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/ysyhl9tian/15698870.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/ytaomg/11211641.java b/codes/ytaomg/11211641.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/ytaomg/11211641.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/yuanps/10188803.java b/codes/yuanps/10188803.java new file mode 100644 index 0000000000000000000000000000000000000000..80f067af421f53792c12e63cebbef5a2784dede9 --- /dev/null +++ b/codes/yuanps/10188803.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;i a[j+1]){ + int a1 = a[j]; + a[j] = a[j+1]; + a[j+1] = a1; + } + } + } +} //end` diff --git a/codes/yulinL/.java b/codes/yulinL/.java new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/codes/yulinL/.java @@ -0,0 +1 @@ + diff --git a/codes/yulinL/13638622.java b/codes/yulinL/13638622.java new file mode 100644 index 0000000000000000000000000000000000000000..785e7d5e62ed2e9d301405dc8d13f64fcd923c0e --- /dev/null +++ b/codes/yulinL/13638622.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int[] a, int n) { + // 你的代码,使无序数组 a 变得有序 + int temp; + for (int i = 0; i < n - 1; i++) { + for (int j = 0; j < n - 1 - i; j++) { + if (a[j] > a[j + 1]) { + temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + } //end diff --git a/codes/yuliwei/15592333.java b/codes/yuliwei/15592333.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/yuliwei/15592333.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/yuyuya/15772019.java b/codes/yuyuya/15772019.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/yuyuya/15772019.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/yuyuyu11/15522885.java b/codes/yuyuyu11/15522885.java new file mode 100644 index 0000000000000000000000000000000000000000..f79136634908ee2d6f79c56a39b719c63106063a --- /dev/null +++ b/codes/yuyuyu11/15522885.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/yuzhanao/15592466.java b/codes/yuzhanao/15592466.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/yuzhanao/15592466.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/yy19047006973/.keep b/codes/yy19047006973/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/yy19047006973/10972205.java b/codes/yy19047006973/10972205.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/yy19047006973/10972205.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/yyds0102/11208011.java b/codes/yyds0102/11208011.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/yyds0102/11208011.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/yyguaiguaizai/15651703.java b/codes/yyguaiguaizai/15651703.java new file mode 100644 index 0000000000000000000000000000000000000000..397e6828cea5dea16731fbbe06a8decb9dee9519 --- /dev/null +++ b/codes/yyguaiguaizai/15651703.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * 该函数用于对一个整型数组进行冒泡排序 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 冒泡排序的主体部分 + for (int i = 0; i < n - 1; i++) { + // 设置一个标志位,表示本趟是否发生过交换 + boolean swapped = false; + for (int j = 0; j < n - i - 1; j++) { + // 如果前一个元素大于后一个元素,则交换它们 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + // 发生了交换,标志位设为 true + swapped = true; + } + } + // 如果本趟没有发生交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/yyh520/15551703.java b/codes/yyh520/15551703.java new file mode 100644 index 0000000000000000000000000000000000000000..fc14461e48f0de625038375ff6dc8f6d38536135 --- /dev/null +++ b/codes/yyh520/15551703.java @@ -0,0 +1,17 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n) { + // 你的代码,使无序数组 a 变得有序 + for (int i=1; i<=n; i++) + for(int j=0; ja[j+1]) { + int t=a[j]; + a[j]=a[j+1]; + a[j+1]=t; + } + +} //end diff --git a/codes/yyui123/15718758.java b/codes/yyui123/15718758.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/yyui123/15718758.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/yyya12/15700309.java b/codes/yyya12/15700309.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/codes/yyya12/15700309.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/codes/z13213005762/15514594.java b/codes/z13213005762/15514594.java new file mode 100644 index 0000000000000000000000000000000000000000..d66c7b0328f84a41b71a062f466c74777cb45a61 --- /dev/null +++ b/codes/z13213005762/15514594.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 冒泡排序是一种简单的排序算法,通过重复地遍历待排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/z13213005762/15515049.java b/codes/z13213005762/15515049.java new file mode 100644 index 0000000000000000000000000000000000000000..d66c7b0328f84a41b71a062f466c74777cb45a61 --- /dev/null +++ b/codes/z13213005762/15515049.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * 冒泡排序是一种简单的排序算法,通过重复地遍历待排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。 + * @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 - 1 - i; j++) { + // 如果当前元素大于下一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/z2468479040/11197656.java b/codes/z2468479040/11197656.java new file mode 100644 index 0000000000000000000000000000000000000000..32b804618c5722f3633fc1dd6a4c3455e0d6da16 --- /dev/null +++ b/codes/z2468479040/11197656.java @@ -0,0 +1,14 @@ + +public static void bubbleSort(int [] a, int n){ + + for(int i = 0 ; i < n - 1 ; i++){ + for(int j = 0 ; j < n - 1 - i ; j++){ + if(a[j] > a[j + 1]){ + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + + } \ No newline at end of file diff --git a/codes/zangzang/9952436.java b/codes/zangzang/9952436.java new file mode 100644 index 0000000000000000000000000000000000000000..481ec544586e454023356184f1ce87ca671a7507 --- /dev/null +++ b/codes/zangzang/9952436.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end \ No newline at end of file diff --git a/codes/zer0_1s/10517202.java b/codes/zer0_1s/10517202.java new file mode 100644 index 0000000000000000000000000000000000000000..dd4dc6902d09bbf3665f819a50988369421ea573 --- /dev/null +++ b/codes/zer0_1s/10517202.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + + + int temp = 0;//临时变量 + for (int j = 0; j < n - 1; j++) { + + + for (int i = 0; i < n-1 -j ; i++) { + + if (a[i] > a[i+1]){ + + //三角交换 + temp = a[i]; + a[i] = a[i+1]; + a[i+1] = temp; + } + } + } + +} //end diff --git a/codes/zeroday/15115160.java b/codes/zeroday/15115160.java new file mode 100644 index 0000000000000000000000000000000000000000..1a4afbe0d388e6ace638b01b4673372ecbf16b22 --- /dev/null +++ b/codes/zeroday/15115160.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/zerofei_tsai/10742215.java b/codes/zerofei_tsai/10742215.java new file mode 100644 index 0000000000000000000000000000000000000000..c64acb7a36ef8cb23b87dff4b419786d987a7e59 --- /dev/null +++ b/codes/zerofei_tsai/10742215.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0; i a[j+1]) { + int tmp = a[j]; + a[j] = a[j+1]; + a[j+1] = tmp; + } + } + } +} //end + diff --git a/codes/zgm1214/15650118.java b/codes/zgm1214/15650118.java new file mode 100644 index 0000000000000000000000000000000000000000..e654b3dbaef07a18a602b1fc53672ca093abd7f8 --- /dev/null +++ b/codes/zgm1214/15650118.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 通过多次遍历数组,比较相邻元素,并交换它们(如果它们的顺序错误)来排序数组 + * @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]) { + // 交换a[j]和a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + // 当所有的循环都完成后,数组a已经被排序 +} // end diff --git a/codes/zhangll/10007624.java b/codes/zhangll/10007624.java new file mode 100644 index 0000000000000000000000000000000000000000..b2626aa5bc7ddedb3154037acef08fc04d0b3e74 --- /dev/null +++ b/codes/zhangll/10007624.java @@ -0,0 +1,21 @@ +/** + * 冒泡排序函数 + * 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+1]; + a[j+1] = a[j]; + a[j] = temp; + } + } + } +} //end diff --git a/codes/zhangpc/10298011.java b/codes/zhangpc/10298011.java new file mode 100644 index 0000000000000000000000000000000000000000..02f03636e6ca97a81bc2b9b110d99d325015c6d9 --- /dev/null +++ b/codes/zhangpc/10298011.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 a[j+1]){ + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +}// end diff --git a/codes/zhangshaopu/9785926.java b/codes/zhangshaopu/9785926.java new file mode 100644 index 0000000000000000000000000000000000000000..10dbc6525b8c4427dda5055b3f3c224c68398d2c --- /dev/null +++ b/codes/zhangshaopu/9785926.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + +} //end diff --git a/codes/zhangwei001/15709943.java b/codes/zhangwei001/15709943.java new file mode 100644 index 0000000000000000000000000000000000000000..7ec373aee12c8b4795c0d670e772620e90ee630e --- /dev/null +++ b/codes/zhangwei001/15709943.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 通过对相邻的元素进行两两比较,顺序相反则进行交换,每一轮比较会将当前未排序部分的最大值“冒泡”到未排序部分的末尾。 + * @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]) { // 如果前一个元素大于后一个元素,则交换它们 + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} // end diff --git a/codes/zhangxiaoQ/15509138.java b/codes/zhangxiaoQ/15509138.java new file mode 100644 index 0000000000000000000000000000000000000000..2c24eacc43419cb4d667adb3abf561f7fc0b12b5 --- /dev/null +++ b/codes/zhangxiaoQ/15509138.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} //end diff --git a/codes/zhao1218jk/.keep b/codes/zhao1218jk/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/zhao1218jk/10981574.java b/codes/zhao1218jk/10981574.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/zhao1218jk/10981574.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/zhaokang/15619865.java b/codes/zhaokang/15619865.java new file mode 100644 index 0000000000000000000000000000000000000000..854beb62bfcf4ead3549d682ffca7f1b9f32d947 --- /dev/null +++ b/codes/zhaokang/15619865.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end + diff --git a/codes/zhenhan0502/.keep b/codes/zhenhan0502/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/zhenhan0502/10987497.java b/codes/zhenhan0502/10987497.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/zhenhan0502/10987497.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/zhizhihua1/15588689.java b/codes/zhizhihua1/15588689.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/zhizhihua1/15588689.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/zhizhixia/15563504.java b/codes/zhizhixia/15563504.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/zhizhixia/15563504.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/zhizi123/15635289.java b/codes/zhizi123/15635289.java new file mode 100644 index 0000000000000000000000000000000000000000..20575dc4ccc75a5bf6af9ea4614fcfa2a84fdeaf --- /dev/null +++ b/codes/zhizi123/15635289.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + // 交换元素 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/zhonggui/11896235.java b/codes/zhonggui/11896235.java new file mode 100644 index 0000000000000000000000000000000000000000..5c5e689d83ba966af24dea37845e9ddafbd6460e --- /dev/null +++ b/codes/zhonggui/11896235.java @@ -0,0 +1,20 @@ + /** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } + + } diff --git a/codes/zhoucheng/11464584.java b/codes/zhoucheng/11464584.java new file mode 100644 index 0000000000000000000000000000000000000000..cacd12f1e4e4360dd1ffa22f3741e376110bcde4 --- /dev/null +++ b/codes/zhoucheng/11464584.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i=0;ia[j+1]){ + a[j] = a[j]+a[j+1]; + a[j+1] = a[j]-a[j+1]; + a[j] = a[j]-a[j+1]; + } + } + } +} //end \ No newline at end of file diff --git a/codes/zk_cxz/15621975.java b/codes/zk_cxz/15621975.java new file mode 100644 index 0000000000000000000000000000000000000000..185aaaa96201d667b365d65de4688434899d66f2 --- /dev/null +++ b/codes/zk_cxz/15621975.java @@ -0,0 +1,27 @@ +/** + * 冒泡排序函数 + * 遍历数组,比较相邻元素,如果顺序错误则交换它们,直到没有元素需要交换,数组排序完成。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 设置一个标志位,表示这一趟是否有交换 + boolean swapped = false; + for (int j = 0; j < n - i - 1; j++) { + // 如果当前元素大于下一个元素,则交换它们 + if (a[j] > a[j + 1]) { + // 交换 a[j] 和 a[j+1] + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + // 如果有交换发生,则将标志位设为 true + swapped = true; + } + } + // 如果这一趟没有发生交换,说明数组已经有序,直接退出循环 + if (!swapped) { + break; + } + } +} //end diff --git a/codes/zl940825/.keep b/codes/zl940825/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/zl940825/10979064.java b/codes/zl940825/10979064.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/zl940825/10979064.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/zl954208/.keep b/codes/zl954208/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/zl954208/10981200.java b/codes/zl954208/10981200.java new file mode 100644 index 0000000000000000000000000000000000000000..9eccfac593dd84bb4c285d230d4de6b8c72a1d65 --- /dev/null +++ b/codes/zl954208/10981200.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} diff --git a/codes/zmq11111/15512070.java b/codes/zmq11111/15512070.java new file mode 100644 index 0000000000000000000000000000000000000000..1a2516ab894c9b768a9595041b5dc91bed1fbb41 --- /dev/null +++ b/codes/zmq11111/15512070.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 冒泡排序的基本原理是通过相邻元素之间的比较和交换,使得较大的元素逐渐从底部浮出到顶部,从而实现排序。 + * @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 - 1 - i; j++) { + // 如果前面的元素大于后面的元素,则交换它们 + if (a[j] > a[j + 1]) { + // 使用临时变量进行交换 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/znnzmm/11212509.java b/codes/znnzmm/11212509.java new file mode 100644 index 0000000000000000000000000000000000000000..272a12fc81d3dd0e857bba9ae001c15818fb7123 --- /dev/null +++ b/codes/znnzmm/11212509.java @@ -0,0 +1,18 @@ + /** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ + public static void bubbleSort(int [] arr, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = (i + 1); j < n; j++) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } //end \ No newline at end of file diff --git a/codes/zouyu5521/11464070.java b/codes/zouyu5521/11464070.java new file mode 100644 index 0000000000000000000000000000000000000000..a833d8d31b2581029ab106b60f560dd2c73ff238 --- /dev/null +++ b/codes/zouyu5521/11464070.java @@ -0,0 +1,24 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } + //System.out.println(a); + +} //end \ No newline at end of file diff --git a/codes/zrccxx/10850939.java b/codes/zrccxx/10850939.java new file mode 100644 index 0000000000000000000000000000000000000000..0006df95feb4980af9f365872e147e284d1a3cfe --- /dev/null +++ b/codes/zrccxx/10850939.java @@ -0,0 +1,12 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } + +} diff --git a/codes/zu15047422887/.keep b/codes/zu15047422887/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/zu15047422887/15607358.java b/codes/zu15047422887/15607358.java new file mode 100644 index 0000000000000000000000000000000000000000..f85a1f87226364dae1535b4ccc25ce57409e4bed --- /dev/null +++ b/codes/zu15047422887/15607358.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换相邻两个元素的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/zu15047422887/15607367.java b/codes/zu15047422887/15607367.java new file mode 100644 index 0000000000000000000000000000000000000000..f85a1f87226364dae1535b4ccc25ce57409e4bed --- /dev/null +++ b/codes/zu15047422887/15607367.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * + * @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 - 1 - i; j++) { + if (a[j] > a[j + 1]) { + // 交换相邻两个元素的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} diff --git a/codes/zuokem6/11118132.java b/codes/zuokem6/11118132.java new file mode 100644 index 0000000000000000000000000000000000000000..9e7534d4b41cf071c848fa4d5c08c6519526b6e3 --- /dev/null +++ b/codes/zuokem6/11118132.java @@ -0,0 +1,18 @@ +/** + * 冒泡 排序 函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i = 0; i < n; i++) { + for (int j = 0; j < i; j++) { + if (a[i] < a[j]) { + int t = a[i]; + a[i] = a[j]; + a[j] = t; + } + } + } +}//end \ No newline at end of file diff --git a/codes/zuotian/15659839.java b/codes/zuotian/15659839.java new file mode 100644 index 0000000000000000000000000000000000000000..cfd796006fa426da9f8d48cb8ecd36cc7c703c54 --- /dev/null +++ b/codes/zuotian/15659839.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 对数组进行冒泡排序,使数组元素按照从小到大的顺序排列 + * @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 - 1 - i; j++) { + // 如果前一个元素大于后一个元素,则交换它们的位置 + if (a[j] > a[j + 1]) { + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end diff --git a/codes/zxc123/15513151.java b/codes/zxc123/15513151.java new file mode 100644 index 0000000000000000000000000000000000000000..a4247277a6725af11de1315df71a8456084a2cf5 --- /dev/null +++ b/codes/zxc123/15513151.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 该算法通过重复遍历待排序的数组,比较相邻元素并交换位置,直到数组有序。 + * @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; + } + } + } + // 排序完成后,数组 a 将变得有序 +} diff --git a/codes/zxcvbaa225/.keep b/codes/zxcvbaa225/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/codes/zxcvbaa225/15735743.java b/codes/zxcvbaa225/15735743.java new file mode 100644 index 0000000000000000000000000000000000000000..6e9861fa3ec6d5a2553cdccd1bb1e977430c671b --- /dev/null +++ b/codes/zxcvbaa225/15735743.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * 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 - i - 1; j++) { + if (a[j] > a[j + 1]) { + + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end \ No newline at end of file diff --git a/codes/zxd30022/10164256.java b/codes/zxd30022/10164256.java new file mode 100644 index 0000000000000000000000000000000000000000..b19d51369a53f34c6b892e36f4d1916ba2a84823 --- /dev/null +++ b/codes/zxd30022/10164256.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for (int i=0;ia[j+1]) { + tmp = a[j+1]; + a[j+1] = a[j]; + a[j] = tmp; + } + } + } +} //end diff --git a/codes/zxf1795065101/15563222.java b/codes/zxf1795065101/15563222.java new file mode 100644 index 0000000000000000000000000000000000000000..ae82e695cbfd360050241c3f1f592658c8c1d4e7 --- /dev/null +++ b/codes/zxf1795065101/15563222.java @@ -0,0 +1,35 @@ +/** + + * 冒泡排序函数 + + * 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-1-i;j++){ + + if(a[j] > a[j+1]){ + + int temp = a[j]; + + a[j] = a[j+1]; + + a[j+1] = temp; + + } + + } + + } + + + +} //end diff --git a/codes/zxg_god/11128523.java b/codes/zxg_god/11128523.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/zxg_god/11128523.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/zxmyigeren/15488956.java b/codes/zxmyigeren/15488956.java new file mode 100644 index 0000000000000000000000000000000000000000..bbd832c4e11df95cc489a13ebf6b07ec8f0c499f --- /dev/null +++ b/codes/zxmyigeren/15488956.java @@ -0,0 +1,33 @@ +/** + * 冒泡排序函数 + * 通过重复走访要排序的数列,一次比较两个元素, + * 如果他们的顺序错误就把他们交换过来。 + * 走访数列的工作是重复地进行直到没有再需要交换, + * 也就是说该数列已经排序完成。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + if (n == 0 || n == 1) { + return; // 如果数组长度为0或1,无需排序直接返回 + } + + boolean swapped; + for (int i = 0; i < n - 1; i++) { + swapped = false; // 每次遍历前假设没有元素需要交换 + 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; + swapped = true; // 发生了交换 + } + } + // 如果一次遍历中没有交换发生,说明数组已经有序,可以结束排序 + if (!swapped) { + break; + } + } +} // end bubbleSort + diff --git a/codes/zxmyigeren/15539430.java b/codes/zxmyigeren/15539430.java new file mode 100644 index 0000000000000000000000000000000000000000..bbd832c4e11df95cc489a13ebf6b07ec8f0c499f --- /dev/null +++ b/codes/zxmyigeren/15539430.java @@ -0,0 +1,33 @@ +/** + * 冒泡排序函数 + * 通过重复走访要排序的数列,一次比较两个元素, + * 如果他们的顺序错误就把他们交换过来。 + * 走访数列的工作是重复地进行直到没有再需要交换, + * 也就是说该数列已经排序完成。 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int[] a, int n) { + if (n == 0 || n == 1) { + return; // 如果数组长度为0或1,无需排序直接返回 + } + + boolean swapped; + for (int i = 0; i < n - 1; i++) { + swapped = false; // 每次遍历前假设没有元素需要交换 + 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; + swapped = true; // 发生了交换 + } + } + // 如果一次遍历中没有交换发生,说明数组已经有序,可以结束排序 + if (!swapped) { + break; + } + } +} // end bubbleSort + diff --git a/codes/zxq777/15540332.java b/codes/zxq777/15540332.java new file mode 100644 index 0000000000000000000000000000000000000000..20bd5f81769363dc0b35fb3104bcced71ab3f178 --- /dev/null +++ b/codes/zxq777/15540332.java @@ -0,0 +1,22 @@ +/** + * 冒泡排序函数 + * 通过重复遍历要排序的数列,一次比较两个元素, + * 如果他们的顺序错误就把他们交换过来。 + * 遍历数列的工作是重复进行的,直到没有再需要交换的元素为止。 + * 该算法的时间复杂度为O(n^2)。 + * @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 - 1 - i; j++){ // 内层循环,控制每次比较的元素数量 + if(a[j] > a[j + 1]){ // 如果前一个元素比后一个元素大 + // 交换两个元素的位置 + int temp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = temp; + } + } + } +} //end + diff --git a/codes/zy2239106/14616675.java b/codes/zy2239106/14616675.java new file mode 100644 index 0000000000000000000000000000000000000000..629658aad6981b30fa2a0033bf9c9bf3eb1db769 --- /dev/null +++ b/codes/zy2239106/14616675.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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; + } + } + } +} //end diff --git a/codes/zyx1373529784/.11255507.java.swp b/codes/zyx1373529784/.11255507.java.swp new file mode 100644 index 0000000000000000000000000000000000000000..9b726027fddbfd97c3f47c01748240b20491682c Binary files /dev/null and b/codes/zyx1373529784/.11255507.java.swp differ diff --git a/codes/zyx1373529784/11255507.java b/codes/zyx1373529784/11255507.java new file mode 100644 index 0000000000000000000000000000000000000000..64421e08ab5325ba6519b736693c153be1bfe018 --- /dev/null +++ b/codes/zyx1373529784/11255507.java @@ -0,0 +1,19 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + int temp; + for (int j = 0; j < n - 1; n--) { + for (int i = 0; i < n - 1; i++) { + if (a[i] > a[i + 1]) { + temp = a[i + 1]; + a[i + 1] = a[i]; + a[i] = temp; + } + } + } +} //end diff --git a/codes/zyy022/15592411.java b/codes/zyy022/15592411.java new file mode 100644 index 0000000000000000000000000000000000000000..c2afaa2414da1853e4500b02c6de9068b64aeafe --- /dev/null +++ b/codes/zyy022/15592411.java @@ -0,0 +1,18 @@ +/** + * 冒泡排序函数 + * 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-1-i;j++){ + if(a[j] > a[j+1]){ + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + +} //end diff --git a/codes/zzcaicai/15725032.java b/codes/zzcaicai/15725032.java new file mode 100644 index 0000000000000000000000000000000000000000..7ce620c3e5da73497f3bd1c48010bf1366a3fe53 --- /dev/null +++ b/codes/zzcaicai/15725032.java @@ -0,0 +1,28 @@ +/** + * 冒泡排序函数 + * 将无序数组通过冒泡排序算法变为有序数组 + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + for (int i = 0; i < n - 1; i++) { + // 设置一个标志位,用于优化算法,减少不必要的比较 + boolean swapped = false; + 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; + // 如果有元素交换,则标志位设为true + swapped = true; + } + } + // 如果没有元素交换,说明数组已经有序,可以提前结束排序 + if (!swapped) { + break; + } + } +} //end + + diff --git a/codes/zzdpop/11212991.java b/codes/zzdpop/11212991.java new file mode 100644 index 0000000000000000000000000000000000000000..1c8889947f924214c71a3c3f202500b4780dc281 --- /dev/null +++ b/codes/zzdpop/11212991.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a,int n){ + 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; + } + } + } +} \ No newline at end of file diff --git a/codes/zzmini/11076797.java b/codes/zzmini/11076797.java new file mode 100644 index 0000000000000000000000000000000000000000..b9bf7818d9ffdce1bf2bd0863a51890bffa3f951 --- /dev/null +++ b/codes/zzmini/11076797.java @@ -0,0 +1,11 @@ +public static void bubbleSort(int [] a, int n) { + for (int i=0 ; ia[j+1]) { + int temp=a[j]; + a[j]=a[j+1]; + a[j+1]=temp; + } + } + } +} \ No newline at end of file diff --git a/l1017026323/15630469.java b/l1017026323/15630469.java new file mode 100644 index 0000000000000000000000000000000000000000..987377810b5beca8eb4bf5eafeee5db45e234a87 --- /dev/null +++ b/l1017026323/15630469.java @@ -0,0 +1,20 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + for(int i = 0; i < n; i++) { + for(int liuy = 0; liuy < n - i - 1; liuy++) { + if(a[liuy] > a[liuy + 1]) { + int temp = a[liuy]; + a [liuy] = a[liuy + 1]; + a[liuy + 1] = temp; + } + } + } + + +} //end,liuy diff --git a/smcO0O/10708545.java b/smcO0O/10708545.java new file mode 100644 index 0000000000000000000000000000000000000000..c04f3701e502fec2a278b85d54d687a7e15dd7f9 --- /dev/null +++ b/smcO0O/10708545.java @@ -0,0 +1,12 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + // 你的代码,使无序数组 a 变得有序 + ... + ... + +} //end