双链表删除节点

本文介绍了如何在C语言中实现双链表的节点删除操作,包括功能函数的定义、具体的功能模块实现和主程序的代码展示。
摘要由CSDN通过智能技术生成

功能函数定义:

#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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值