两个递增数据组合成一个递增数据(不适用)

public class ListArrayApp {

public static void main(String[] args) {

int[] a = { 1, 3, 5 };
int[] b = { 2, 6 };
int l = a.length + b.length;
int[] c = new int[l];
int i = 0, j = 0, k = 0;

while (i < a.length && j <= b.length) {
if (a[i] < b[j]) {
c[k] = a[i];
i++;
} else {
c[k] = b[j];
j++;
}
k++;
}
if(a[a.length-1]<b[b.length-1]){
c[c.length-1]= b[b.length-1];
}else{
c[c.length-1]=a[a.length-1];
}
for (int m : c) {
System.out.print(m+" ");
}
}
}

原文地址:https://www.cnblogs.com/qadyyj/p/5488866.html