チェーンテーブルc++コードの実現


//説明:データをテストするときは、主関数に厳格に従ってデータをテストしてください.このチェーンテーブルはすべての入力データが正しいと仮定しているので..むやみに入力したら.私は境界検査を書いていません.
//今回の書き方は比較的簡潔です.皆さんの勉強に便利です.
 
 
 
 
 
#include "iostream"
using namespace std;
typedef struct Node
{
char ch;
struct Node *nex;
}List;
void Init(List *&L)//   
{
L=new List;
L->nex=NULL;
}
void show(List *L)//  
{
List *p=L->nex;
while(p!=NULL)
{
cout<ch<nex;
}
cout<nex=new List;
p=p->nex;
cin>>p->ch;
p->nex=NULL;
}
}
void Insert(List *&L,char key,int index)//  key    INDEX    
{
int j=0;
List *p=L;
while(jnex;
}
List *s;
s=new List;
s->nex=NULL;
s->ch=key;
s->nex=p->nex;
p->nex=s;
}
void Del(List *&L,int index)//     index  
{
int j=0;
List *p=L;
while(jnex;
}
p->nex=p->nex->nex;
}
int main()
{
int n,q;
List *L;
while(cin>>n>>q)//n  Q   
{
Init(L);
Create(L,n);
while(q--)
{
int x;
cin>>x;
if(x==1)//  
{
char key;
int index;
cin>>key>>index;
Insert(L,key,index);
show(L);
}
else if(x==2)//  
{
show(L);
}
else//  
{
int index;
cin>>index;
Del(L,index);
show(L);
}
}
}
return 0;
}