How Do You Write A Function That Can Reverse A Linked-list In C++

How Do You Write A Function That Can Reverse A Linked-list In C++


  • 4 Feb, 2012

    void reverselist(void){ if(head==0) return; if(head-<next==0) return; if(head-<next==tail) { head-<next = 0; tail-<next = head; } else { node* pre = head; node* cur = head-<next; node* curnext = cur-<next; head-<next = 0; cur-<next = head; for(; curnext!=0; ) { cur-<next = pre; pre = cur; cur = curnext; curnext = curnext-<next; } curnext-<next = cur; }}

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.