Loading

插入排序_JAVA

public class Main {
    public static void main(String[] args) {
        int[] A = { 6, 4, 3, 5, 6, 2 };
        for (int j = 1; j < A.length; j++) {
            int key = A[j];
            int i = j - 1;
            while (i >= 0 && A[i] > key) {
                A[i + 1] = A[i];
                i--;
            }
            A[i + 1] = key;
        }
    }
}        

 

posted @ 2016-09-21 09:36  hackyo  阅读(177)  评论(0编辑  收藏  举报