第十七次发博不知道用什么标题好

双向链表的插入

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;

    }

}

 

posted @ 2019-04-23 23:57  18软工8班段诗媛  阅读(78)  评论(0编辑  收藏  举报