c 链表
来源:互联网 发布:org.apache.mina 编辑:程序博客网 时间:2024/06/05 03:52
接口头文件
/* * linklist.h * * Created on: 2012-11-11 * Author: inner */#ifndef LINKLIST_H_#define LINKLIST_H_#include <stdbool.h>#define SIZE 30//struct film{//char title[SIZE];//int rating;//};//typedef struct film Item;typedef int Elem;typedef struct node{Elem elem;struct node *next;} Node;typedef Node *linkList;/*初始化链表*/void InitializeList(linkList *list);/* 添加节点*/void addNodeList(linkList *list,Elem elem);/*获取节点数量*/int getListCount(linkList *list);#endif /* LINKLIST_H_ */
实现源文件
/* * link.c * * Created on: 2012-11-11 * Author: inner */#include<stdio.h>#include <stdlib.h>#include"linklist.h"void InitializeList(linkList *list){*list = NULL;}void addNodeList(linkList *list, int elem){Node *p;//下一节点Node *list1 = *list;p =(Node *)malloc(sizeof(Node));p->elem = elem;p->next = NULL;/*判断头结点是否空*/if(list1 == NULL){ *list= p;}else{while(list1->next != NULL) list1 = list1->next;list1->next = p;}}int getListCount(linkList *list){int count = 0;Node *node = *list;while(node->next!=NULL){++count;node = node->next;}return count;}
就写这么多了有时间再更新
- C链表
- c 链表
- 链表(C#)
- C链表
- C 链表
- [C]链表
- C 链表
- 【C++】链表
- C 链表
- c链表
- C-链表
- c 链表
- C链表
- c链表
- 链表 c
- C++:链表
- C 链表
- C语言泛型初探----C链表
- Tinyxml解析xml优化(vc6.0调试ok)
- Deep learning的一些有用链接
- WebStorm V5.0破解版含注册码
- MongoDB基本介绍及一些用法
- 自学CCIE路由协议疑难解答
- c 链表
- Deep Learning Reading List
- jquery.ui.datepicker 添加时分秒
- ASPxGridViewHelper自定义多表头及合并单元格
- 一个程序员关于学习的思考顺带思考人生
- CUE脚本编辑器
- jquery 文字滚动
- Java数字格式化
- ubuntu_xp更改启动顺序的方法