怎么样将两个数组a[],b[]的元素存入另外一个数组c[]中并排序?
------解决方案--------------------
直接把a和b的数据复制到c里面去,然后对c进行排序
- Java code
import java.util.*;public class Test{ public static void main(String[] args) { int[] a = new int[] {1, 2, 5, 7}; int[] b = new int[] {3, 4, 6, 8}; int[] c = new int[a.length + b.length]; System.arraycopy(a, 0, c, 0, a.length); System.arraycopy(b, 0, c, a.length, b.length); Arrays.sort(c); System.out.println(Arrays.toString(a)); System.out.println(Arrays.toString(b)); System.out.println(Arrays.toString(c)); }}
------解决方案--------------------