单链表反转

list* reverse(list* list){
    plist head = list;

    if (head)
    {
        plist next = list->next;
        head->next = NULL;
        
        while(next){
            plist temp = next->next;
            next->next = head;
            head = next;
            next = temp;
        }
        
    }
    return head;
}

你可能感兴趣的:(单链表反转)