标签:blog 2014 log ad as br file return ip
之前做过链表的翻转,这里看到一个更简单的实现
ListNode* Reverse(ListNode *head) { ListNode *reHead = NULL; ListNode *prev = NULL; ListNode *Node = head; while(Node != NULL) { ListNode *next = Node->next; if(next == NULL) reHead = Node; Node->next = prev; prev = Node; Node = next; } return reHead; }
还有
ListNode* reverse(ListNode *head){ if(head == NULL || head->next == NULL ) return head; ListNode* tmp = reverse(head->next); head->next->next = head; head->next = NULL; return tmp; }
标签:blog 2014 log ad as br file return ip
原文地址:http://blog.csdn.net/sina012345/article/details/41973795