mirror of
https://github.com/ViolentAyang/DataStructureC.git
synced 2026-02-03 02:13:14 +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;
|
||||
}LNode,*LinkList;
|
||||
|
||||
bool InitList(LinkList L){
|
||||
L = (LinkList)malloc(sizeof(LNode));
|
||||
if(!L){
|
||||
return false;
|
||||
}
|
||||
L->next = L;
|
||||
return true;
|
||||
}
|
||||
//判断链表是否为空
|
||||
bool isEmpty(LinkList L){
|
||||
if(!L->next){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//判断结点p是否为循环链表的表尾结点
|
||||
bool isTail(LinkList L,LNode *p){
|
||||
if(p->next==L){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user