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

文章作者 100test 发表时间 2007:10:24 12:50:48
来源 100Test.Com百考试题网


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

}LNode,*Linklist.
BOOL HeadNOde(Linklist* Head,Linklist* L,int temp)
...{
*Head = (Linklist )malloc(sizeof(LNode)).
*L = (Linklist )malloc(sizeof(LNode)).
if((!*Head)||(!*L))
...{
return ERROR.
}
(*Head)->next = *L.
(*L)->data = temp.
(*L)->next = NULL.
return TRUE.
}
BOOL InsertList(Linklist* L,int temp)
...{

Linklist L1 = (Linklist )malloc(sizeof(LNode)).
if(!L1)
...{
return ERROR.
}
L1->data = temp.
L1->next = *L.
*L=L1.
return TRUE.
}
int main()
...{
Linklist Head,List.
int temp = 10.
HeadNOde(&.Head,&.List,temp).
for(int i=0.i<10.i )
...{
InsertList(&.List,i).
}
Linklist pList.
pList = List.
while(pList)
...{
printf("%d ",pList->data).
pList = pList->next.
}

return 0.
}


相关文章


C 私有成员变量的访问权限研究
VC 编译选项说明
防止窗口闪烁的方法
灵活使用GOTO语句
用C语言封装的链表的方法
miranda中Service与Event机制分析其结果
qsort()排序函数的使用qsort函数应用大全
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛