冒泡排序

将数组相邻的两个元素比较,将小的数和大的数交换位置,否则不交换

public static void bubbleSort(int []a){
        for(int i = 0;i < a.length-1; i++){
            for(int j = i+1; ja[j]) {
                    int temp = a[i];
                    a[i] = a[j];
                    a[j] = temp;
                }
            }
        }
    }

你可能感兴趣的:(冒泡排序)