4.17啊啊啊啊啊啊啊啊

#include"double_list.h"
node_p create_list();
{
	node_p h=(node_p)malloc(sizeof(node));
	if(h==NULL)
	{
		printf("创建空间失败\n");
		return NULL;
	}
	h->data=0;
	h->next=NULL;
	h->pri=NULL;
	return h;


}
node_p create(int data)
{
	node_p new=(node_p)malloc(sizeof(node));
	if(new==NULL)
	{
		printf("节点创建失败\n");
		return NULL;
	}
	new->data=data;
	return new;
}
void insert_head(node_p h,int data)
{
	if(h==NULL)
	{
		printf("入参为\n");
		return;
	}

	node_p new=create(data);
	new->next=h->next;
	new->pri=h;
	h->next->pri=new;
	h->next=new;
	h->data++;
}

int empty_double(node_p h)
{
	if(h=NULL)
	{
		printf("入参为空\n");
		return 1;
	}
	return h->next==NULL?1:0;
}

void del_head(node_p h)
{
	if(h=NULL)
	{
		printf("入参为空\n");
		return;
	}
	if(empty_double(h))
	{
		printf("列表为空\n");
		return;
	}
	node_p del=h->next;
	h->next=h->next->next;
	h->next->next->pri=h;
	h->data--;
	
}

void insert_end(node_p h,int data)
{
	if(h=NULL)
	{
		printf("入参为空\n");
		return;
	}
	if(empty_double(h))
	{
		printf("列表为空\n");
		return;
	}
	node_p p=h;
	while(p->next!=NULL)
	{
		p=p->next;
		}
	node_p new=create(data0;
	new->next=p->next;
	new->pri=p;
	p->next->pri=p;
	p->next=new;


}
void del_end(node_p h)
{
	if(h=NULL)
	{
		printf("入参为空\n");
		return;
	}
	if(empty_double(h))
	{
		printf("列表为空\n");
		return;
	
	}
	node_p p=h;
	while(p->next!=NULL)
	{
		p=p->next;
	}
	node_p del=p->next;
	p->next=p->next->next;
	p->next->next->pri=p;
	h->data--;
	p->pri=p;


}
void insert_pos(node_p h,int data,int pos)
{
	if(h=NULL)
	{
		printf("入参为空\n");
		return;
	}
	if(empty_double(h))
	{
		printf("列表为空\n");
		return;
	}
	if(pos<=0||pos>h->data)
	{
		printf("插入的位置错误\n");
		return;
	}
	node_p p=h;
	for(int i=o;i<pos-1;i++)
	{
		p=p->next;
	}
	node_p new=create(data);
	new->next=p->next;
	new->pri=p;
	p->next->pri=new;
	p->next=new;
	h->data++;



}
void del_pos(node_p h,int data,int pos)
{
	if(h=NULL)
	{
		printf("入参为空\n");
		return;
	}
	if(empty_double(h))
	{
		printf("列表为空\n");
		return;
	}
	node_p p=h;
	for(int i=o;i<pos;i++)
	{
		p=p->next;

	}
	node_p del=p->next;
	p->next=p->next->next;
	p-next->next->pri=p;
	h->data--;
    





}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值