#include <iostream>
using namespace std;
typedef int ElemType;
typedef struct Node{
ElemType e;
struct Node * next;
}Node,*LinkList;
void initList(LinkList &L){
L = new Node;
L->next = NULL;
}
//插入
void insertList(LinkList &L, ElemType e){
LinkList p = new Node;
p->e = e;
p->next = L->next;
L->next = p;
}
//输出
void outputList(LinkList &L){
LinkList p = L->next;
if (p == NULL)
{
cout<<"此链表为空链表"<<endl;
}
else{
while (p != NULL)
{
cout<<p->e<<endl;
p = p->next;
}
}
}
//求表长
int getLength(LinkList &L){
int i = 0;
LinkList p = L;
while (p->next != NULL)
{
i++;
p = p->next;
}
return i;
}
//查找值为e的结点
bool hasList(LinkList &L, ElemType e){
LinkList p = L->next;
while (p != NULL)
{
if(p->e == e){
return true;
}
p = p->next;
}
return false;
}
//查找第i个位置的元素
void searchIndex(LinkList &L, int index){
int length1 = getLength(L);
if (index<=0 || index>length1)
{
cout<<"您输入的索引超过了线性表的长度范围。"<<endl;
}
&nb