mirror of
https://github.com/ViolentAyang/DataStructureC.git
synced 2026-02-02 18:10:59 +08:00
Create 双链表的初始化.c
This commit is contained in:
35
链表/双链表的初始化.c
Normal file
35
链表/双链表的初始化.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
void List_Print(DLinkList L){
|
||||
DLinkList p = L->next;
|
||||
printf("链表的元素为:\n");
|
||||
while(p){
|
||||
printf("%d\t",p->data);
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
DLinkList L;
|
||||
InitDlinkList(L);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user