复习归并排序

复习下算法
========归并=======
    public void MergeList() {
        Integer[] ia = new Integer[] {1,2,3,4,5,6,7,8,9};
        Integer[] ib = new Integer[] {2,3,4,5,6,6,8,9,10,12,15,19,200};
        Integer[] ic = new Integer[ia.length + ib.length];
        int i = 0;
        int j = 0;
        int k = -1;
        while (i<ia.length && j<ib.length) {
             if(ia[i]>=ib[j]) {
                 ic[++k] = ib[j++];
             }else {
                 ic[++k] = ia[i++];
             }
        }
        while (i<ia.length) {
            ic[++k] = ia[i++];
        }
        while (j<ib.length) {
            ic[++k] = ib[j++];
        }
        for (Integer integer : ic) {
           System.out.println(integer);
        }
    }

你可能感兴趣的:(算法,J#)