链表相邻元素交换

typedef struct LinkNode  
{  
    int data;  
    struct LinkNode* next;  
}LinkNode , *LinkList;  
  
LinkList inverseList(LinkList head)  
{  
    if(head == NULL || head->next == NULL)  
        return head;  
    LinkList pre = NULL;  
    LinkList curr = head;  
    LinkList next = NULL;  
  
    while(curr && curr->next)  
    {  
        if(pre)  
            pre->next = curr->next;  
        else  
            head = curr->next;  
  
        pre = curr;  
        next = curr->next->next;  
        curr->next->next = curr;  
        curr->next = next;  
        curr = next;   
    }  
    return head;  
}  
原文地址:https://www.cnblogs.com/liuweilinlin/p/3327726.html