题目:
输入一个链表,反转链表后,输出链表的所有元素。
struct ListNode
{
int value;
ListNode *next;
};
void ReverseList( ListNode** pHead )
{
if ( pHead == NULL || *pHead == NULL || (*pHead)->next == NULL )
return ;
ListNode* pPre = NULL;
ListNode* pCur = *pHead;
ListNode* pNext = (*pHead)->next;
(*pHead)->next = NULL;
while ( pNext != NULL )
{
pPre = pCur;
pCur = pNext;
pNext = pCur->next;
pCur->next = pPre;
}
(*pHead) = pCur;
}
6万+



被折叠的 条评论
为什么被折叠?



