pNode FindMiddleNode(pList plist)
{
/*
快慢指针,快的两步,慢的一步
*/
pNode pFast = plist;
pNode pSlow = plist;
while (pFast&&pFast->next)
{
pFast = pFast->next->next;
pSlow = pSlow->next;
}
return pSlow;
}
查找单链表的中间结点,要求只能遍历一次链表
猜你喜欢
转载自blog.csdn.net/weixin_40995778/article/details/82825069
今日推荐
周排行