原题目:https://leetcode-cn.com/problems/odd-even-linked-list/
代码:
class Solution {
public:
ListNode* oddEvenList(ListNode* head) {
if(head==NULL) return head;
ListNode*p,*q,*t;
p = head;q=head;
while(q->next&&q->next->next){
q = q->next;t = q->next;
q->next = t->next;t->next=p->next;p->next=t;
p=p->next;
}
return head;
}
};