From b6e5cd4b6725b59ab913c87e7fc31620d9715f49 Mon Sep 17 00:00:00 2001 From: 18882611826 <3042856566@qq.com> Date: Mon, 15 Apr 2024 15:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=92=E5=BA=8F=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/he3042856566.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 codes/he3042856566.java diff --git a/codes/he3042856566.java b/codes/he3042856566.java new file mode 100644 index 000000000..c2afaa241 --- /dev/null +++ b/codes/he3042856566.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 -- Gitee