第十七次发博不知道用什么标题好
双向链表的插入
typedef struct node{
Elemtype data;
struct nide *prior;
struct node *next;
}Dlist;
int insElem(Dlist *L,Elemtype x,int i){
int j=0;
Dlist *p,*s;
*p=L;
if(p==NULL) return 0;
else {
s=(Dlist *)malloc(sizeof(Dlist));
s->data=x;
s->next=p->next; //①
if(p->next==NULL)
p->next->prior=s; //②
s->prior=p; //③
p->next=s; //④
return 1;
}
}