package com.forezp.util;

import java.util.Arrays;



/**
 * 两个int数组,都是从小到大的的排列,请合并为一个新的数组,也是从小到到大的排列,
 * 请写出性能最优的算法。<br>
 * 
 * 
 * 
 * @author Administrator
 *
 */
public class ArrayDemo1 {
    public static void main(String[] args) {
        int[] a = { 1,3,5,7,9};
        int[] b = { 2,4,6,7,8,10};
        
        int[] c = new int[a.length+b.length];
        
        //将a,b的数据copy到c中
        System.arraycopy(a, 0, c, 0, a.length);
        System.arraycopy(b, 0, c, a.length, b.length);
        
        Arrays.sort(c);
        
        
        for (int i : c) {
            System.out.print(i);
        }
        
    }
}

 

 

运行结果:

JAVA常见算法题(二十八)

 

相关文章:

  • 2021-10-29
  • 2022-12-23
  • 2022-02-14
  • 2021-12-22
  • 2021-08-05
  • 2022-01-29
  • 2021-11-14
猜你喜欢
  • 2021-11-19
  • 2021-08-13
  • 2022-12-23
  • 2021-06-23
  • 2021-04-02
  • 2021-06-08
相关资源
相似解决方案