#include <stdio.h>
#include <stdlib.h>
#include<assert.h>
typedef int sdatatype;
typedef struct slistnode//单链表节点
{
sdatatype _data;
struct slistnode *pnext;
}node, *pnode;
typedef struct slist//给一个头指针保存第一个节点的地址
{
pnode _phead;
}slist, *pslist;
pnode endKlist(slist *s, int K) {
assert(s);//断言非空
int count1 = 1;//计数所有结点数
int count = 0;
pnode p1 = s->_phead;
pnode p2 = s->_phead;
while (p1->pnext != NULL) {
p1 = p1->pnext;
count1++;
}
K = count1 - K;
while (count!=K) {
p2 = p2->pnext;
count++;
}
return p2;
}