C实现循环双链表
2012-07-13 09:09
190 查看
/************************************** C实现循环双链表 **************************************/ #include<stdio.h> #include<stdlib.h> struct DuLNode { int num; struct DuLNode *prior,*next; }; struct DuLNode *head=NULL; cre_list() //初始化结点 { head = (struct DuLNode *)malloc(sizeof(struct DuLNode)); head->prior = head; head->next = head; } add_DuLNode(int num) //插入结点 { struct DuLNode *ptr = (struct DuLNode *)malloc(sizeof(struct DuLNode)); ptr->num = num; ptr->next=head->next; head->next=ptr; ptr->prior=head; ptr->next->prior=ptr; } display_DuLNode() //遍历链表 { struct DuLNode *p = head; do { printf("%d\t",p->num); p = p->next; }while(p!=head); printf("\n"); } delete_DuLNode(int num) //删除 { struct DuLNode *p,*q; p = head; do { if(p->num == num) { q=p->next; p->prior->next=q; q->prior=p->prior; free(p); p=q; } else { p=p->next; } }while(p != head); } int main() { int i=0; cre_list(); for(i;i<10;i++) { add_DuLNode(i); } display_DuLNode(); delete_DuLNode(5); display_DuLNode(); return 0; }
相关文章推荐
- 文件检索(C循环双链表实现)
- 循环双链表的简单实现
- !实现循环双链表各种基本运算的算法
- “循环双链表”实际代码宣布实现【物联网1132-11】
- 循环双链表之Java实现(模拟JDK中LinkedList)
- 实验二(3)用循环双链表实现对数据的基本操作
- 模板实现顺序表和循环双链表
- 编写一个程序实现循环双链表的各种基本运算(假设顺序表的元数基本类型为Char)
- 循环双链表基本操作C++实现
- 循环双链表的C++实现
- C语言实现非循环双链表节点的删除(不带头结点)
- 数据结构之循环双链表的结构和实现
- 循环双链表的基本操作实现
- c语言之————有头循环双链表实现队列存储
- Linux内核-从sk_buff{}结构学习“双循环双链表”的实现
- 数据结构学习----线性表的链式表示之循环双链表(Java实现)
- 循环双链表的简单实现
- 数据结构之循环双链表的结构和实现
- 循环双链表的实现
- 循环双链表的基本操作实现