《数据结构》(第2版)陈越
#include <iostream>
using namespace std;
typedef struct LNode *PtrToLNode;
struct LNode{
//定义链表结点的结构
int Data;
PtrToLNode Next;
};
typedef PtrToLNode Position;//代表结点的地址
typedef PtrToLNode List;
int Length(List L){
//1.求表长
Position p;//移动指针;
int cnt = 0;//初始化计数器
p = L;//p指向链表的第一个结点
while(p){
//p != NULL
cnt++;
p = p->Next;//当前p指向的是第cnt个结点
}
return cnt;
}
//查找
int FindKth(List L, int K)