用C语言封装的链表的方法

用C语言封装的链表的方法,第1张

用C语言封装的链表的方法,第2张

# include
# include
# define TRUE 1
# define ERROR 0
# define BOOL int
typedef struct LNode
...{
int data;
LNode * next;

}LNode,* Linklist
BOOL Head node(Linklist * Head,Linklist* L,int temp)
...{
* Head =(Linklist)malloc(sizeof(LNode));
* L =(Linklist)malloc(sizeof(LNode));
如果((!*头)||(!*L))
...{
返回错误;
}
(* Head)-> next = * L;
(* L)-> data = temp;
(* L)-> next = NULL;
返回TRUE
}
BOOL insert list(Linklist * L,int temp)
...{

链表L1 =(Linklist)malloc(sizeof(LNode));
如果(!L1)
...{
返回错误;
}
L1-> data = temp;
L1-> next = * L;
* L = L1;
返回TRUE
}
int main()
...{
Linklist Head,List
int temp = 10;
HeadNOde(&Head,&List,temp);
for(int I = 0;我...{
InsertList(&List,I);
}
Linklist pList;
pList = List;
while(pList)
...{
printf("%d ",pList-> data);
pList = pList-> next;
}

返回0;
}

位律师回复
DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
白度搜_经验知识百科全书 » 用C语言封装的链表的方法

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情