C语言中链表的英文名字,数据结构C语言版 循环链表表示和实现(国外英文).doc

数据结构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, 2011

* /

#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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值