#include
#include
typedef int element;
typedef struct list
{
element data;
struct list *prior,*next;
}DLINK_LIST;
DLINK_LIST*conet_linklist();//双向链表的创建
void insertbefore_linklist(DLINK_LIST*q,DLINK_LIST*S);//将s插入到q的前面
void delet_linklist(DLINK_LIST*S);//删除指定节点
void main()
{
DLINK_LIST*head;
head=conet_linklist();
if(head!=NULL)
printf("链表创建成功!\n");
else
printf("链表创建失败!\n");
}
DLINK_LIST*conet_linklist()
{
DLINK_LIST*head,*tail;
DLINK_LIST*p;
element x;
head=(DLINK_LIST*)malloc(sizeof(DLINK_LIST));
if(head==NULL)
return NULL;
else
tail=head;
printf("请输入数据:\n");
scanf("%d",&x);
while(x!=0)
{
p=(DLINK_LIST*)malloc(sizeof(DLINK_LIST));
if(p==NULL)
return p;
else
{
tail->next=p;
p->prior=tail;
tail=p;
tail->next=NULL;
scanf("%d",&x);
}
}
return head;
}
void insertbefore_linklist(DLINK_LIST*q,DLINK_LIST*S)//按指定节点进行插入
{
s->prior=q->prior;
s->next=q;
q->prior->next=s;
q->prior=s;
}
void delet_linklist(DLINK_LIST*S)//删除指定节点
{
s->next->prior=s->prior;
s->prior->next=s->next;
free(s);
}
原文链接:https://blog.csdn.net/qq_44213634/article/details/91288253
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.