#题目

#代码
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode() {}
* ListNode(int val) { this.val = val; }
* ListNode(int val, ListNode next) { this.val = val; this.next = next; }
* }
*/
class Solution {
public ListNode swapPairs(ListNode head) {
ListNode xuni=new ListNode(0,head);
ListNode cur=xuni;
while(cur.next!=null && cur.next.next!=null){
ListNode node1 =cur.next;//第一个节点
ListNode node2 =cur.next.next;//第二个节点
cur.next=node2;
node1.next=node2.next;
node2.next=node1;
cur=cur.next.next;
}
return xuni.next;
}
}