pNode FindLastKNode(pList plist, int k)
{
pNode pFast = plist;
pNode pSlow = plist;
if (plist == NULL || k <= 0)
{
return NULL;
}
while (k--)//pFast先走k步
{
if (pFast == NULL)//k大于链表中结点的个数
{
return NULL;
}
pFast = pFast->next;
}
while (pFast)//两个指针同时朝后走
{
pFast = pFast->next;
pSlow = pSlow->next;
}
return pSlow;
}