单链表反转程序

typedef struct node{
    int data;
    node* next;
    };
    
void reverse(node *head){
    if(head==NULL||head->next==NULL)return;
    linka *pre,*cur,*ne;
    pre=head;
    cur=head->next;
    while(cur)
    {
        ne=cur->next;
        cur->next=pre;
        pre=cur;
        cur=ne;
        }
        head->next=pre;
        return;
    }

 

posted on 2014-11-18 10:58  矮油~  阅读(232)  评论(0)    收藏  举报

导航