package com.jalor;
public class AAAA {
public static void main(String[] args) {
int[] arr = {1,4,6,333,8,2};
Bubble(arr);
}
public static void Bubble(int[] arr){
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]) {
int t = arr[j];
arr[j] = arr[j+1];
arr[j+1] = t;
}
}
}
for (int i : arr) {
System.out.print(i+"\t");
}
}
}
JAVA实现冒泡排序(绝版)
最新推荐文章于 2024-06-07 09:15:00 发布