List Merge(List L1, List L2) {
List DummyHead = (List) calloc(1,sizeof(List));
List pa = DummyHead, p1 = L1->Next, p2 = L2->Next;
L1->Next = NULL;
L2->Next = NULL;
while (p1 || p2) {
if (!p1) {
pa->Next = p2;
break;
} else if (!p2) {
pa->Next = p1;
break;
} else {
if (p1->Data <= p2->Data) {
pa->Next = p1;
p1 = p1->Next;
} else {
pa->Next = p2;
p2 = p2->Next;
}
pa = pa->Next;
}
}
return DummyHead;
}
- 文章链接: https://nbb.lol/index.php/archives/72/
- 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!