单链表反转程序

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;

    }

 

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