[PTA] 数据结构与算法题目集 6-1 单链表逆转
List Reverse(List L)
{
List p, q;
p = L;
q = L;
L = NULL;
while (p)
{
p = p->Next;
q->Next = L;
L = q;
q = p;
}
return L;
}
List Reverse(List L)
{
List p, q;
p = L;
q = L;
L = NULL;
while (p)
{
p = p->Next;
q->Next = L;
L = q;
q = p;
}
return L;
}