mirror of
https://github.com/ViolentAyang/DataStructureC.git
synced 2026-02-02 18:10:59 +08:00
Create 双链表的删除.c
This commit is contained in:
41
链表/双链表的删除.c
Normal file
41
链表/双链表的删除.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct DNode{
|
||||
int data;
|
||||
struct DNode *next,*prior;
|
||||
}DNode,*DLinkList;
|
||||
|
||||
bool InitDlinkList(DLinkList L){
|
||||
L = (DLinkList)malloc(sizeof(DNode));
|
||||
if(L==NULL){
|
||||
return false;
|
||||
}
|
||||
L->prior = NULL;
|
||||
L->next =NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeleteNextNode(DNode *p){
|
||||
if(!p){
|
||||
return false;
|
||||
}
|
||||
DNode* q = p;
|
||||
if(!q){
|
||||
return false;
|
||||
}
|
||||
p->next = q->next;
|
||||
if(q->next){
|
||||
q->next->prior = p;
|
||||
}
|
||||
free(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
DLinkList L;
|
||||
InitDlinkList(L);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user