数据结构c语言版 循环链表表示和实现(Data structure, C language, circular list representation and Implementation).docVIP

  • 8
  • 0
  • 约 20页
  • 2017-10-07 发布于河南
  • 举报

数据结构c语言版 循环链表表示和实现(Data structure, C language, circular list representation and Implementation).doc

数据结构c语言版 循环链表表示和实现(Data structure, C language, circular list representation and Implementation)

数据结构c语言版 循环链表表示和实现(Data structure, C language, circular list representation and Implementation) 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, 2011 * / #include stdio.h #include malloc.h #include stdlib.h 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 t

文档评论(0)

1亿VIP精品文档

相关文档