struct ListNode* oddEvenList(struct ListNode* head) { if(head==NULL || head->next==NULL) return head; struct ListNode *odd = head; struct ListNode *even = head->next,*even_head = even; struct ListNode *p = NULL; while(odd->next&&even->next){ p = odd->next->next; //记录下一个奇数点 even->next = p->next; //先让偶数点连接下一个偶数点 odd->next = p; //奇数点连接下一个奇数点 odd = p; //奇数点后移 even = p->next; //偶数点后移 } odd->next = even_head; return head; }