#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--;
}
4.17啊啊啊啊啊啊啊啊
最新推荐文章于 2024-07-24 17:27:32 发布