zoukankan      html  css  js  c++  java
  • java排序 冒泡?+插入排序

    冒泡.
    public
    class insortSort { public static void main(String[] args) { int[] arr = {12, 3, 4, 55, 36, 17, 45, 18, 36}; for (int i = 1; i < arr.length; i++) { for (int j = i - 1; j >= 0; j--) { if (arr[i] < arr[j]) { int temp = arr[j]; arr[j] = arr[i]; arr[i] = temp; } } } for (int b : arr ) { System.out.println(b); } } }
    package 真插入;
    
    /**
     * Created by zekaialways give up on 2017/7/21.
     */
    public class RealInsortSort {
        public static void main(String[] args) {
            int temp,j;
            int[] a = {6, 2, 4, 1, 8, 3, 9, 11};
            for (int i = 1; i < a.length; i++) {
                temp = a[i];
                for (j = i - 1; j >= 0 && a[j] > temp; j--) {
                    a[j + 1] = a[j];
                }
                a[j + 1] = temp;
            }
            for (int b : a
                    ) {
                System.out.println(b);
    
            }
    
        }
    }
  • 相关阅读:
    Redis 分布式锁
    Angular VS Blzaor
    Chorme 跨域的快捷解决
    旋转3角形
    .Netcore AD 操作
    .Netcore 2.2 和3.1 的模板
    Command3
    CSS Selector
    弹性盒子
    Label_strange_labels
  • 原文地址:https://www.cnblogs.com/tangzekai/p/7214581.html
Copyright © 2011-2022 走看看