功能函数定义:
#ifndef __DBLIST_H__
#define __DBLIST_H__
#include <stdio.h>
#include <stdlib.h>
typedef struct list
{
union
{
int len;
int data;
};
struct list *next;
struct list *before;
}dblist;
//创建头节点
dblist *db_create();
//创建节点
dblist *node_create();
//头插
int insert_head(dblist *L,int in_data);
//打印
int print_dblist(dblist *L);
//判空
int dblist_empty(dblist *L);
//尾插
int insert_tail(dblist *L,int in_data);
//位置插入
int insert_pos(dblist *L,int pos,int in_data);
//按位置删除
int del_pos(dblist *L,int pos);
#endif
功能模块:
#include "dblist.h"
dblist *db_create()
{
dblist *L=(dblist*)malloc(sizeof(dblist));
if(L==NULL){
printf("申请失败\n");
return NULL;
}L->len=0;
L->before=NULL;
L->next=NULL;
return L;
}
dblist *node_create()
{
dblist *L=(dblist*)malloc(sizeof(dblist));
if(L==NULL){
printf("申请失败\n");
re