5. 链表
来源:互联网 发布:apache auth身份认证 编辑:程序博客网 时间:2024/05/01 23:01
5. 链表
5.1 链表是由一连串节点组成的,其中每个节点都包含指向下一个节点的指针。struct node{
int value;
struct node *next;
};
5.2 添加链表节点
struct node *first = NULL;
struct node *new_node = malloc(sizeof(struct node));
new_node->value = 1;
new_node->next = first;
first = new_node;
// 添加新节点
struct node *add_to_list(struct node *list,int n){
struct node *new_node;
new_node = malloc(sizeof(struct node));
new_node->value=n;
new_node->next = list;
return new_node;
}
5.3 搜索链表
// 搜索链表
struct node *seatch_list(struct node *list,int n){
struct node *p;
for(p = list;p!=NULL;p=p->next){
if(p->value==n){
return p;
}
}
return NULL;
}
该博客教程视频地址:http://geek99.com/node/1004
原文出处:http://geek99.com/node/861#
0 0
- 5. 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- 链表
- C++异常与结构化异常SEH的比较
- iOS 开发常用的一些工具
- 百度浏览器,一款简单轻快绿色纯净的浏览器
- The Way They Move: Tracking Muitiple Targets with Similar Appearance文章思想及其代码分析
- Memcache负载均衡配置
- 5. 链表
- C++静态库与动态库
- 交换机、集线器、路由器区别和作用
- margin重叠
- CMD命令执行停不下来的问题
- m2eclipse 误报 “Missing artifact”真相
- OK6410 SD卡一键烧写WinCE6.0串口输出消息
- 【JJ斗地主官网下载】在线斗地主比赛赢大奖,中文棋牌游戏
- JS零碎知识点学习笔记