#include <iostream>
using namespace std;
struct Node
{
int data;
Node *next;
}*PNode;
PNode findRerKElem(Node *L,int n)
{
if( n == 0)return L;
Node *k = L, *s = L;
int i = 1;
while(s != NULL && s->next != NULL)
{
if( i++ < n)s = s->next;
else
{
k = k->next;
s = s->next;
}
}
return k;
}
输出单向链表的倒数第K个元素
最新推荐文章于 2022-04-25 23:21:11 发布