void Reverse (PLinkList* ppList)
{ Node* newHead = NULL;
assert(ppList);
if (*ppList != NULL)
{
// 取第一个节点做新的头结点
newHead = *ppList;
Node* begin = (*ppList)->next;
newHead->next = NULL;
// 取节点进行头插
while (begin != NULL)
{
Node* tmp = begin;
begin = begin->next;
tmp->next = newHead;
newHead = tmp;
}
}
*ppList = newHead;
时间: 2024-10-27 08:20:43