* 单链表反转另外一种写法 */
LinkedList *ListReverse(LinkedList *L)
{
LinkedList *current, *pNext;
if (L == NULL) return NULL; //链表不存在,这里L指的是头结点
if (L->next == NULL) return L;
current = L->next;
while (current->next != NULL)
{
pNext = current->next;
current->next = pNext->next;
pNext->next = L->next;
L->next = pNext;
}
return L;
}
很好的总结:http://www.nowamagic.net/librarys/veda/detail/2241