输出该链表中倒数第k个结点
ListNode* FindKthToTail(ListNode* pListHead, unsigned int k)
{
if(pListHead == NULL || k < 1)
return NULL;
ListNode *pAhead = pListHead;
ListNode *pBehind = NULL;
for(unsigned int i=0; i < k-1; ++i)
{
if(pAhead->next != NULL)
pAhead = pAhead->next;
else
return NULL;
}
pBehind = pListHead;
while(pAhead->next != NULL)
{
pAhead = pAhead->next;
pBehind = pBehind->next;
}
return pBehind;
}