mirror of
https://github.com/ViolentAyang/DataStructureC.git
synced 2026-05-05 20:43:46 +08:00
Create 创建带头结点的单链表.c
This commit is contained in:
36
链表/创建带头结点的单链表.c
Normal file
36
链表/创建带头结点的单链表.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<stdbool.h>
|
||||
|
||||
typedef struct LNode{
|
||||
int data;
|
||||
struct LNode *next;
|
||||
}LNode,*LinkList;
|
||||
|
||||
bool InitList(LinkList *L){
|
||||
(*L) = (LNode*)malloc(sizeof(LNode));
|
||||
if(*L==NULL){
|
||||
return false;
|
||||
}
|
||||
(*L)->next = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Empty(LinkList L){
|
||||
if(L->next==NULL){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int main(){
|
||||
LinkList L;
|
||||
InitList(&L);
|
||||
if(Empty(L)){
|
||||
printf("分配成功");
|
||||
}else{
|
||||
printf("分配失败");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user