合并数组并排序
2017-05-08 17:42
274 查看
将合并数组合并,并按升序排列
运行结果:
1
2
3
4
5
5
6
7
7
9
10
11
13
15
17
19
int s[] ={1,3,5,7,9,11,13,15,17,19}; int b[] ={2,4,5,6,7,10}; int [] c= new int[s.length+b.length]; System.arraycopy(s, 0, c, 0, s.length); System.arraycopy(b, 0, c, s.length, b.length); Arrays.sort(c); for (int j = 0; j < c.length; j++) { System.out.println(c[j]); } /* public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length) Parameters: src - the source array. srcPos - starting position in the source array. dest - the destination array. destPos - starting position in the destination data. length - the number of array elements to be copied. */
运行结果:
1
2
3
4
5
5
6
7
7
9
10
11
13
15
17
19
相关文章推荐
- 数组合并,排序,和查找
- 已知m和n是已经排序好的数组,从小到大,现在要合并这两个数组内的数到一个数组,仍然要求是从小到大排序
- 合并两个排序数组
- 两个已排序的数组进行合并
- 合并两个静态数组并排序
- 已知m和n是已经排序好的数组,从小到大,现在要合并这两个数组内的数到一个数组,仍然要求是从小到大排序
- JQuery中 数组与字符串(过滤,排序,拆分,合并)
- 将两个整形数组排序后合并成一个数组
- 链表节点合并排序:数组和单链表
- C# 合并两个int数组 合并后根据大小排序 并输出
- C# 合并数组、排序、删除重复项最优方案
- 算法题 -- 合并两个大小为n的已排序数组
- 第二章之“合并排序中对小数组采用插入排序”(思考题2-1)
- java中合并无序数组并进行排序
- 合并两个已经排序的数组
- c# 合并数组后排序输出
- JQuery中 数组与字符串(过滤,排序,拆分,合并)
- 排序算法的数组实现 -- 合并排序(三)
- [排序数组合并]
- 两个数组合并,去掉重复的然后再排序