解
// 帶頭結點的單鏈表的逆置
Status ListOppose_L(LinkList &L)
{
LinkList p
p=L;
p=p
L
while(p){
q=p;
p=p
q
L
}
return OK;
}
解
// 將合並逆置後的結果放在C表中
Status ListMergeOppose_L(LinkList &A
{
LinkList pa
pa=A;
pb=B;
qa=pa;// 保存pa的前驅指針
qb=pb;// 保存pb的前驅指針
pa=pa
pb=pb
A
C=A;
while(pa&&pb){
if(pa
qa=pa;
pa=pa
qa
A
}
else{
qb=pb;
pb=pb
qb
A
}
}
while(pa){
qa=pa;
pa=pa
qa
A
}
while(pb){
qb=pb;
pb=pb
qb
A
}
pb=B;
free(pb);
return OK;
}
解
// 將A
Status ListCross_Sq(SqList &A
{
int i=
while(i<A
if(A
else
if(A
else{
ListInsert_Sq(C
i++;
k++;
}
}
return OK;
}
[
From:http://tw.wingwit.com/Article/program/sjjg/201311/23404.html