标签:main 有序 ring rgs 有序数组 for logs public static
public static int[] twoArray(int[] a, int[] b) { int i =0; int j = 0; int k = 0; int aLen = a.length; int bLen = b.length; int[] arra = new int[aLen + bLen]; while (i < aLen && j < bLen) { if (a[i] < b[j]) { arra[k] = a[i]; i++; } else { arra[k] = b[j]; j++; } k++; } if (i == aLen) { while(j < bLen) { arra[k] = b[j]; k++; j++; } } if (j == bLen) { while(i < aLen) { arra[k] = a[i]; k++; i++; } } for(int m = 0; m < arra.length; m++) { System.out.print(arra[m] + ","); } return arra; } public static void main(String[] args) { int[] a = {1,2,6,9}; int[] b = {5,7,8,9,10}; twoArray(a, b); }
标签:main 有序 ring rgs 有序数组 for logs public static
原文地址:http://www.cnblogs.com/wangxiaowang/p/7818777.html