谁能帮我写个数据结构(C语言)顺序表的合并的程序,谢谢了
1个回答
展开全部
void MergeList(List la,List lb,list &lc)
{
IninList(lc);
I=j=1;k=0;
la_len=ListLength(la);lb_len=ListLength(lb);
while(I<=la_len&&j<=lb_len)
{GetElem(la,I,ai);GetElem(lb,j,bj);
if(ai<=bj){ListList(lc,++k,ai);I++;}
else {ListInsert(lc,k++,bj);j++;}
}
while(I<=la_len)
{GetElem(la,I++,ai);ListInsert(lc,k++,ai);}
while(j<=lb_len)
{GetElem(lb,j++,bj);ListInsert(lc,k++,bj);}
}
{
IninList(lc);
I=j=1;k=0;
la_len=ListLength(la);lb_len=ListLength(lb);
while(I<=la_len&&j<=lb_len)
{GetElem(la,I,ai);GetElem(lb,j,bj);
if(ai<=bj){ListList(lc,++k,ai);I++;}
else {ListInsert(lc,k++,bj);j++;}
}
while(I<=la_len)
{GetElem(la,I++,ai);ListInsert(lc,k++,ai);}
while(j<=lb_len)
{GetElem(lb,j++,bj);ListInsert(lc,k++,bj);}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询