数据结构 算法 — 合并顺序表

void MergeLIst_ Sq(SqList La, SqList Lb, SqList &Lc){ //顺序表的合并

pa=La.elem;
pb=Lb.elem;
Lc.listsize = Lc.length = La.length+Lb.length;
pc= Lc.elem=(ElemType*)malloc(Lc.listsize*sizeof(ElemType));
if (!Lc.elem)exit(OVERFLOW);
pa_ last=La.elem+La.length-1;
pb_ last=Lb.elem+Lb.length-1;
while (pa<= pa_ last && pb<=pb_ last){
if(*pa<=*pb)*pc++=*pa++;
else *pc++=*pb++;

}
while(pa<=pa_ list)*pc++ = *pa++;
while(pb<=pb_ list)*pc++ = *pb++;
}

posted @ 2016-07-17 16:38  李香兰-javaee程序媛  阅读(479)  评论(0编辑  收藏  举报