public static void main(String[] args) { bubbleSort(new int[]{3,20,11,50,33,44,60,4}); } public static void bubbleSort(int[] array) { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array.length - 1 - i; j++) { if (array[j] > array[j + 1]) { int temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; } } } for (int i = 0; i < array.length; i++) { System.out.print(array[i] + " "); } }
冒泡排序.....
最新推荐文章于 2024-09-08 22:26:10 发布