05_氣泡排序
4 3 2 1
1 4 3 2
1 2 4 3
1 2 3 4
public static void bubble_sort(int[] arr) {
for (int j = 0; j < arr.length - 1; j++) {
for (int i = arr.length - 1; i > j; i--) {
if (arr[i-1] > arr[i]) {
int temp = arr[i];
arr[i] = arr[i-1];
arr[i-1] = temp;
}
}
}
};