方法一
L *link(L *head)
{
L *p, *q;
p = head->next;
head - >next = NULL;
while ( q ! = NULL)
{
q = p->next;
p = head->next;
head->next = p;
p = q;
}
return head;
}
将原先的链表节点摘取下来,使用头结点插入的方法再插入,最后实现单链表的逆序
方法二
L *link(L *head)
{
L *pre , *p = head->next, *r = p->next;
p->next = NULL;
while (r != NULL)
{
pre = p;
p=r;
r = r->next;
p->next = pre;
}
head->next = p
return head;
}