单链表反转

 1 void reverseLinkedList(LinkedList list)
 2 {
 3     if (NULL == list || NULL == list->next)
 4         return list;
 5     
 6     LinkedList temp,prev,next;
 7     prev = list;
 8     temp = list->next;
 9     prev->next = NULL;
10     
11     while(temp != NULL)
12     {
13     next = temp->next;
14     temp->next = prev;
15     prev = temp;
16     temp = next;
17     }
18     return prev;
19 }

 

posted @ 2016-03-15 19:47  Crazystonely  阅读(93)  评论(0编辑  收藏  举报