冒泡排序

public class MyBubbleSort {
    public static void main(String[] args) {
        int num[] = {10,8,33,54,1,6,12,43,32,27};
        bubbleSort(num);
        for (int i = 0; i < num.length; i++) {
            System.out.print(num[i] + " ");
        }
    }

    private static void bubbleSort(int[]num){
        for (int i = 0; i < num.length ; i++) {
            for (int j = i+1; j < num.length ; j++) {
                if (num[i]>num[j]){
                    int temp = num[i];
                    num[i] = num[j];
                    num[j] = temp;
                }
            }
        }
    }
}
原文地址:https://www.cnblogs.com/zz-1120-wtenlb/p/13358957.html