单链表反转

来源:互联网 发布:java httpclient 302 编辑:程序博客网 时间:2024/06/05 17:32



* 单链表反转另外一种写法 */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


0 0