冒泡排序

//冒泡排序
    public static void main(String[] args) {
        int [] nums = {12,21,11,1,1314,341};
        for(int i = 0; i<nums.length-1; i++) {
            for(int j = 0; j<nums.length-1-i; j++) {
                if(nums[j]>nums[j+1]) {
                    int tem = 0;
                    tem = nums[j];
                    nums[j] = nums[j+1];
                    nums[j+1] = tem;
                }
            }
        }
        for (int i : nums) {
            System.out.println(i);
        }
    }
posted @ 2020-01-07 15:55  AxeBurner  阅读(95)  评论(0编辑  收藏  举报