#include<stdio.h>
#include<stdlib.h>
typedef struct LNode{
int data;
struct LNode* next;
}LNode,*LinkList;
bool InitList(LinkList &L){
L= (LNode*)malloc(sizeof(LNode));
if(L==NULL)
return false;
L->next=NULL;
return true;
}
bool Empty(LinkList L){
return(L->next==NULL);
}
bool InsertNextNode(LNode *p,int e){
if(p==NULL)
return false;
LNode* s=(LNode*)malloc(sizeof(LNode));
if(s==NULL)
return false;
s->data=e;
s-next=p->next;
p->next=s;
return true;
}
LNode* GetElem(LinkList L,int i){
if(i<1)
return false;
LNode* p;
int j=0;
p=L;
while(p!=NULL&&j<i-1){
p=p->next;
j++;
}
return p;
}
bool ListInsert(LinkList &L,int i,int e){
if(i<1)
return false;
LNode* p;
p=L;
int j=0;
while(p!=NULL&&j<i-1){
p=p->next;
j++;
}
InsertNextNode(p,e);
return true;
}
bool DeleteNode(LNode*p){
if(p==NULL)
return false;
LNode* q=p->next;
p->data=q->data;
p->next=q->next;
free(q);
return true;
}
bool ListDelete(LinkList &L,int i,int &e){
LNode*p=GetElem(L,i);
if(p==NULL)
return false;
if(p->next==NULL)
return false;
LNode*q=p->next;
e=q->data;
p->next=q->next;
free(q);
return true;
}
LinkList List_TailInsert(LinkList &L){
int x;
L=(LinkList)malloc(sizeof(LNode));
LNode *s,*r=L;
scanf(“%d”,&x);
while(x!=9999){
s=(LNode*)malloc(sizeof(LNode));
s->data=x;
r->next=s;
r=s;
scanf(“%d”,&x);
}
r->next=NULL;
return L;
}
LinkList List_HeadInsert(LinkList &L){
int x;
LNode *s;
L=(LinkList)malloc(sizeof(LNode));
L->next=NULL;
scanf(“%d”,&x);
while(x!=9999){
s=(LNode*)malloc(sizeof(LNode));
s->data=x;
s->next=L->next;
L->next=s;
scanf(“%d”,&x);
}
return L;
}
int main(){
return 0;
}