Reverse

Node* Reverse(Node* head)
{
    Node *p0, *p1, *temp;
    p0 = NULL;
    p1 = head;
 
    while (p1 != NULL) {
        temp = p1->next;
        p1->next = p0;
        p0 = p1;
        p1 = temp;
    }
 
    return p0;       // if head == NULL, p0 is also NULL
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License