编写一个函数,实现单链表逆序。
typedef struct _NODE
{
int value;
struct _NODE * next;
}NODE, *PNODE;
void Reverse(PNODE * ppHead)
{
if (!(NULL == *ppHead || NULL == (*ppHead)->next))
{
PNODE p1, p2, p3;
p1 = *ppHead;
p2 = p1->next;
p3 = p2->next;
p2->next = p1;
while (p3 != NULL)
{
p1 = p2;
p2 = p3;
p3 = p3->next;
p2->next = p1;
}
(*ppHead)->next = NULL;
*ppHead = p2;
}
}