/** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ struct ListNode* middleNode(struct ListNode* head){ struct ListNode* fast=head; struct ListNode*slow=head; while(fast!=NULL&&fast->next!=NULL)//继续的条件,fast,fast->next有一个为空就停下来了 { fast=fast->next->next; slow=slow->next; } return slow; }