双向链表的插入
为甚么不对,如何该,:Status ListInsert_DuL(DuLinkList &L,int n)
{
DuLNode *p,*s;
if(!L) return ERROR;
ElemType e;
s=(DuLNode *)malloc(sizeof(DuLNode));
if(!s) return ERROR;
if(n<=0) return ERROR;
cin>>e;
s->data=e;
s->next=L->next;
L->next=s;
s->prior=L;
for(int i=1;i<n;i++){
cin>>e;
s=(DuLNode *)malloc(sizeof(DuLNode));
s->data=e;
p=L;
while(p->next&&(p->next->data)<=(s->data))
p=p->next;
s->prior=p;
p->next=s;
s->next=p->next;
p->next->prior=s;
}
return OK;
}