首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

合拢数组(非递减排列)

2012-09-18 
合并数组(非递减排列)//俩个非递减线性表合并 ,新线性表也非递减排列package org.sepublic class arithMe

合并数组(非递减排列)


//俩个非递减线性表合并 ,新线性表也非递减排列
package org.se;


public class arithMetic12 {



public static int la[]={1,4,5,7,9};
public static int lb[]={1,2,3,5,8,11,13,14};
public static int[] lc=new int[13];
static int la_len=la.length;
static int lb_len=lb.length;
static int i=1;
static int j=1;
static int k=0;
public static void ListInsert()
{
int ai=0,bi=0;
while(i<=la_len&&j<=lb_len)
{
ai=la[i-1];
bi=lb[j-1];
if(ai<=bi)
{
lc[k]=ai;++k;++i;
}
else 
{
lc[k]=bi;++k;++j;
}
}
while(i<=la_len)
{
lc[k]=la[i-1]; ++i;++k;
}
while(j<=lb_len)
{
lc[k]=lb[j-1];++k;++j;
}

}
public static void PlayShow()
{
for(int a=0;a<k;a++)
{
System.out.println("lc["+a+"]..."+lc[a]);
}
}
合拢数组(非递减排列)

public static void main(String arg[])
{
ListInsert();
PlayShow();
}
}

热点排行