C语言程序设计吴赟婷卢钢第9章结构体和共用体介绍课件教学.pptVIP

  • 18
  • 0
  • 约10千字
  • 约 61页
  • 2017-01-01 发布于广东
  • 举报

C语言程序设计吴赟婷卢钢第9章结构体和共用体介绍课件教学.ppt

PPT研究院 POWERPOINT ACADEMY * * * 链表的删除操作 ... ai-1 ai ai+1 ... ③ p-next = q-next; ④ free(q); ② q = p-next; p q ① if(p-next满足删除条件) 例:在建好的链表中,删除指定结点。可编写一个删除节点的函数del()。 struct st *del(struct st *h,int num) { struct st *p,*q; if(h==NULL) {printf(“链表不存在”);goto end;} p=h; while(num!=p-nump1-next==NULL) /*p指向的不是指定结点,并且后面还有结点*/ {p=q;p=p-next;} /*p往后移动,指向下一个结点*/ if(num==p-num) /*找到指定结点*/ {if(p==h) h=p-next; else q-next=p-next; printf(“删除%d”,num);} else printf(“%d没有被找到”,num); end; return h; } 链表的插入操作 ... ai ai+1 ... ④ p-next = q; ② q = malloc(sizeof (struct node));  q-data = x; p ① if(p满足插入条件) q x

文档评论(0)

1亿VIP精品文档

相关文档