剑指offer第二题 逆转链表
作者:互联网
struct ListNode* ReverseList(struct ListNode* pHead ) {
// write code here
struct ListNode* p = pHead;
struct ListNode* r ;
struct ListNode* new = NULL;
while(p!=NULL)
{
r=p->next;
p->next = new;
new = p;
p=r;
}
return new;
}
标签:ListNode,struct,offer,next,链表,pHead,new,NULL,逆转 来源: https://blog.csdn.net/Orange_Fanta/article/details/122354895