轉載別人的博客,考慮的很全面。
(1)鏈表的基本知識:
https://blog.csdn.net/morixinguan/article/details/68951912
(2)將兩個有序的鏈表合並。
https://blog.csdn.net/u012155923/article/details/52629526
(3)鏈表翻轉
1>非遞歸實現的程序
node* reverseList(node* H)
{
if (H == NULL || H->next == NULL) //鏈表為空或者僅1個數直接返回
return H;
node* p = H, *newH = NULL;
while (p != NULL) //一直迭代到鏈尾
{
node* tmp = p->next; //暫存p下一個地址,防止變化指針指向后找不到后續的數
p->next = newH; //p->next指向前一個空間
newH = p; //新鏈表的頭移動到p,擴長一步鏈表
p = tmp; //p指向原始鏈表p指向的下一個空間
}
return newH;
}
