struct ListNode* oddEvenList(struct ListNode* head ) { if(head == NULL) return NULL; struct ListNode* odd = head; //第一个奇数位结点 struct ListNode* even = head->next; //第一个偶数位结点 struct ListNode* phead = even; //用于最后将两链表链接起来的接口 while(even != NULL && even->next != NULL){ odd->next = even->next; //指向下一个奇数位结点 odd = odd->next; //移动指针 even->next = odd->next; //指向下一个偶数位结点 even = even->next; //移动指针 } odd->next = phead; //最后一个奇数位结点和第一个偶数位结点链接起来 return head; }