public static int[] merge() {
int[] a = { 1, 3, 56, 78, 98, 322, 9234 };
int[] b = new int[] { 10, 40, 56, 78, 100 };
int l = a.length;
int ml = b.length;
int[] c = new int[a.length + b.length];
int m = 0;
int i = 0;
// 以a为基准
while (m < ml && i < l) {
if (a[i] <= b[m]) {
c[i + m] = a[i];
i++;
} else {
c[i + m] = b[m];
m++;
}
}
// 如果b还有剩余,那么全部加载到c
while (m < ml) {
c[i + m] = b[m];
m++;
}
while (i < l) {
c[i + m] = a[i];
i++;
}
return c;
}