创建一个没有头结点的单链表(学艺不精,必须分开讨论吗)
void CreateList_R(LNode *&L, int n){
L = new LNode;
cin>>L->data;
L->next = NULL;
LNode *r = L;
for(int i=0; i<n-1; i++){
LNode *p = new LNode;
cin>>p->data;
p->next = NULL;
r->next = p;
r = p;
}
}
删除
void Del(LNode *&L, int x){
LNode *p = L;
if(L==NULL) return;
if(p->data == x){
p = L;
L = L->next;
free(p);
Del(L,x);
}
else
Del(L->next,x);
}