归并排序
来源:互联网 发布:我知谁掌管明天 背景 编辑:程序博客网 时间:2024/05/02 01:58
归并排序
package com.buaa.algorithm.sort;/** * 归并排序 * @author lzxyzq * */public class d2mergesorted { static int[]merge(int[]a,int[]b){ int[]x = new int[a.length+b.length]; int ai=0; int bi=0; int xi=0; while(ai<a.length&&bi<b.length){ if(a[ai]<=b[bi]) x[xi++]=a[ai++]; else x[xi++]=b[bi++]; } while(ai<a.length) x[xi++]=a[ai++]; while(bi<b.length) x[xi++]=b[bi++]; return x; } public static void main(String[] args) { int[]a = {5,8,11,19,22,25}; int[]b = {7,9,20,30,35,38,40}; int[]c = merge(a,b); for(int i=0;i<c.length;i++) System.out.println(c[i]); }}
0 0
- 归并排序-归并排序
- 归并和归并排序
- 归并与归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 排序::归并
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 归并排序
- 1016
- Light oj 1112 - Curious Robin Hood【单点更新】
- 在web开发中ActionContext和ServletActionContext的比较
- 几种常见的集合
- 动态库的链接和链接选项-L,-rpath-link,-rpath
- 归并排序
- java中文乱码问题
- 【POJ 3070】Fibonacci(矩阵快速幂)
- iOS开发中数据库常用的语句
- [bzoj4569][SCOI2016]萌萌哒
- Windows Batch 1-4
- 心形图。撩妹用
- HDU1003 Max Sum(经典DP,)
- POJ 2632 Crashing Robots