From 92e0dcc3cb41d35bdf6a7a5fc8351b024cd280d4 Mon Sep 17 00:00:00 2001 From: wasd2890 <3228875734@qq.com> Date: Tue, 26 Mar 2024 13:30:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=92=E5=BA=8F=E7=AE=97?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codes/qindada/15660294.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 codes/qindada/15660294.java diff --git a/codes/qindada/15660294.java b/codes/qindada/15660294.java new file mode 100644 index 00000000..21f05547 --- /dev/null +++ b/codes/qindada/15660294.java @@ -0,0 +1,23 @@ +/** + * 冒泡排序函数 + * aa bb cc + * @param a 待排序的数组 + * @param n 待排序的数组长度 + */ +public static void bubbleSort(int [] a, int n){ + //冒泡排序的时间复杂度为O(n*n) + int temp = 0;//临时变量 + for (int j = 0; j a[i+1]){ + //三角交换 + temp = a[i]; + a[i] = a[i+1]; + a[i+1] = temp; + } + } + } + + +} //end -- Gitee