数据结构C语言版 循环链表表示和实现(国外英文)
数据结构C语言版 循环链表表示和实现(国外英文资料)
Data structure, C language, circular list representation and implementation of.Txt
*
Data structure, C language, circular list representation and Implementation
P35
Compile environment: Dev-C++ 4.9.9.2
Date: February 10,
* /
#include
#include
#include
Typedef int ElemType;
/ / single stranded linear table storage structure
Typedef struct LNode
{
ElemType data;
Struct LNode *next;
}LNode, *LinkList;
To distinguish what is / / the first node ((*L) ->next), the tail node (*L), and the first node
/ / point (*L) ->next->next, the establishment of circular linked list tail pointer (end to end, the head node
/ / and the tail node is the same, they have no data domain.
/ / constructing an empty circular list L
Int InitList_CL (LinkList *L)
{
Have / head node and the L, pointing to the head
*L = (LinkList) malloc (sizeof (struct, LNode));
If (... *L)
Exit (0);
/ / pointer field toward the head node, so as to form a circular, empty table loop, *L table tail
(*L) ->next = *L;
Return 1;
}
The destruction of the circular list / / L
Int DestroyList_CL (LinkList *L)
{
LinkList q,
P = ->next (*L); / / P refers to the head node
While (P! = *L) / / not to the table for table tail tail, *L
{
Q = p->next;
Free (P);
P = q;
}
Free (*L);
*L = NULL;
Return 1;
}
/ / reset L to the empty table
Int ClearList_CL (LinkList *L)
{
LinkList, P, q;
*L= (*L ->next); / / L points to the first node
P= (*L ->next); / / P refers to the first node
While (P! =*L) / / not to list.
{
Q=p->next;
Free (P);
P=q;
}
->next=*L (*L); / / the first node pointer domain refers to itself
Return 1;
}
/ / if L is empty table, it returns 1, otherwise it returns 0
Int ListEmpty_CL (LinkList L)
{
If (L->next==L) / / empty
Return 1;
Else
Return 0;
}
/ / returns the number of elements in the L data
Int ListLength_CL (LinkList L)
{
Int i=0;
LinkList p=L->next; / / P refers to the head node
While (P! =L) / / not to list.
{
I++;
P=p->next;
}
Return i;
}
When / / th
如果觉得《C语言中链表的英文名字 数据结构C语言版 循环链表表示和实现(国外英文).doc》对你有帮助,请点赞、收藏,并留下你的观点哦!