C语言程序设计之入门课程4精选.ppt

* 6 head 8 12 13 null p 15 g r 说明:1312,继续比较。 * 6 head 8 12 13 p 15 g r null 说明:1315,找到了正确的插入位置,则插入结点 p;语句为: rnext = p; p-next = g; * // 结构7.c #include stdio.h // 预编译命令 #include malloc.h // 内存空间分配 #define null 0 // 定义空指针常量 #define LEN sizeof(struct numST) // 定义常量,表示结构长度 struct numST // 结构声明 { int num; // 整型数 struct numST *next; // numST结构指针 }; 参考程序 * // 被调用函数insert(),两个形参分别表示链表和待插入的结点 void insert (struct numST **phead, struct numST *p) { // 函数体开始 struct numST *q,*r; // 定义结构指针q,r if ((*phead)==null) // 第一种情况,链表为空 { *phead = p; // 链表头指向p return; // 完成插入操作,返回

文档评论(0)

1亿VIP精品文档

相关文档