/**
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param head ListNode类
* @return ListNode类
*/
struct ListNode* swapPairs(struct ListNode* head ) {
struct ListNode* dummy=(struct ListNode*)malloc(sizeof(struct ListNode));
dummy->val=0;
dummy->next=head;
struct ListNode* cur=dummy;
while(cur->next!=NULL&&cur->next->next!=NULL){
struct ListNode* node1=cur->next;
struct ListNode* node2=cur->next->next;
node1->next=node2->next;
cur->next=node2;
node2->next=node1;
cur=node1;
}
struct ListNode* newHead=dummy->next;
return newHead;
// write code here
}