数据结构---顺序表
来源:互联网 发布:淘宝怎样和卖家联系 编辑:程序博客网 时间:2024/06/05 05:24
采用指针来实现
链式存储的链表
ChainListType *ChainListAddEnd(ChainListType *head,DATA data)
{ChainListType *node,*h;
if(!(node =(ChainListType *)malloc(sizeof(ChainListType)) ))
{
printf("malloc error");
return NULL;
}
node->data = data;
node->next = NULL;
if(head == NULL)
{
head = node;
return head;
}
h = head;
while(h->next != NULL)
h = h->next;
h->next = node;
return head;
}
ChainListType *ChainListAddFirst(ChainListType *head,DATA data)
{
ChainListType *node,*h;
if(!(node =(ChainListType *)malloc(sizeof(ChainListType)) ))
{
printf("malloc error");
return NULL;
}
node->data = data;
node->next = head;
head = node;
return head;
}
ChainListType *ChainListInsert(ChainListType *head,char *findkey,DATA data)
{
ChainListType *node,*node1;
if(!(node = (ChainListType *)malloc(sizeof(ChainListType) ) ))
{
printf("malloc error");
return 0;
}
node->data = data;
node1 = ChainListFind(head,findkey);
if(node1)
{
node->next = node1->next;
node1->next = node;
}
else
{
free(node);
printf("not find position");
}
return head;
}
ChainListType *ChainListFind(ChainListType *head,char *key)
{
ChainListType *h;
h = head;
while(h)
{
if(strcmp(h->data.key,key) == 0 )
return h;
h = h->next;
}
return NULL;
}
int ChainListDelete(ChainListType *head,char *key)
{
ChainListType *node,*h;
node=h=head;
while(h)
{
if(strcmp(h->data.key,key) == 0)
{
node->next = h->next;
free(h);
return 1;
}
else
{
node = h;
h = h->next;
}
}
return 0;
}
int ChainListLength(ChainListType *head)
{
ChainListType *h;
int i = 0;
h = head;
while(h)
{
i++;
h = h->next;
}
return i;
}
0 0
- 数据结构之 顺序表
- 数据结构--顺序线性表
- 数据结构---顺序表
- 数据结构之顺序表
- 数据结构顺序表
- 数据结构顺序表
- 顺序表(数据结构)
- 数据结构之顺序表
- 数据结构之顺序表
- 数据结构笔记--顺序表
- 【数据结构】顺序表
- 数据结构《顺序链表》
- 数据结构之顺序表
- 数据结构试验 顺序表
- 数据结构--顺序表
- 数据结构--顺序表
- 数据结构之顺序表
- 基本数据结构:顺序表
- Linux中的工作队列
- 滑动控件自定义使用
- Ubuntu16.04 Modelsim 10.2c安装
- 【学习笔记】java面向对象复习03
- C++实验5-字符串
- 数据结构---顺序表
- c++作业5
- 网络是否连接
- 西电捷通:一文读懂数字证书通用管理技术基础常识
- Struts(5)Struts标签介绍
- yii2 命令行运行
- getDimension()、getDimensionPixelOffset()和getDimensionPixelSize()区别详解
- jQuery学习笔记
- Data Integration学习笔记 --- OLAP联机分析处理