资 源 简 介
双向循环链表节点:数据域+指针域指针域:一个指针指向前一个同类型节点,另一个指针指向后一个同类型节点(1)设计节点struct db_node{int data;struct db_node * prev;struct db_node * next;};(2)创建空链表//创建了一个只有头节点的双向循环链表,返回头节点的地址struct db_node * create_db_list(void){struct db_node * phead = (struct db_node *)malloc(sizeof(struct db_node));if(phead == NULL)exit(-1);else{phead->next = phead;phead->prev = phead;}return phead;}(3)制造新节点//制造新节点,返回新节点的地址struct db_node * make_db_node(int value){struct db_node * pnew = (struct db_node *)malloc(sizeof(struct db_node));if(pnew == NULL)printf("malloc failed!
");else{pnew->data = value;pnew->next = NULL;pnew->prev = NULL;}return pnew;}(4)插入节点//把pnew指向的节点插入到头节点的前面,也就是整个链表的末尾bo