数据结构---顺序表
来源:互联网 发布:deepin linux软件源 编辑:程序博客网 时间:2024/06/06 02:18
采用数组存储数据
typedef struct
{
DATA ListData[MAXSIZE+1];
int ListLen;
}SeqListType;
void SeqListInit(SeqListType *SL)
{SL->ListLen = 0;
}
int SeqListLength(SeqListType *SL)
{
return (SL->ListLen);
}
int SeqListAdd(SeqListType *SL,DATA data)
{
if(SL->ListLen >= MAXSIZE)
{
printf(" list is full \n");
return 0 ;
}
SL->ListData[++SL->ListLen] = data;
return 1;
}
int SeqListInsert(SeqListType *SL,int n,DATA data)
{
int i;
if(SL->ListLen >= MAXSIZE)
{
printf("list is full\n");
return 0 ;
}
if(n < 1 || n > SL->ListLen-1)
{
printf("insert error\n");
return 0;
}
for(i=SL->ListLen;i>=n;i--)
{
SL->ListData[i+1] = SL->ListData[i];
}
SL->ListData[n] = data;
SL->ListLen++;
return 1;
}
int SeqListDelete(SeqListType *SL,int n)
{
int i;
if(n < 1 || n > SL->ListLen +1)
{
printf("delete error\n");
return 0;
}
for(i=n;i<SL->ListLen;i++)
SL->ListData[i] = SL->ListData[i+1];
SL->ListLen--;
return 1;
}
DATA *SeqListFindByNum(SeqListType *SL,int n)
{
if(n < 1 || n > SL->ListLen +1)
{
printf("node error \n");
return NULL;
}
return &(SL->ListData[n]);
}
int SeqListFindByCont(SeqListType *SL,char *key)
{
int i;
for(i=1;i<=SL->ListLen;i++)
if(strcmp(SL->ListData[i].key,key) == 0)
return i;
return 0;
}
0 0
- 数据结构之 顺序表
- 数据结构--顺序线性表
- 数据结构---顺序表
- 数据结构之顺序表
- 数据结构顺序表
- 数据结构顺序表
- 顺序表(数据结构)
- 数据结构之顺序表
- 数据结构之顺序表
- 数据结构笔记--顺序表
- 【数据结构】顺序表
- 数据结构《顺序链表》
- 数据结构之顺序表
- 数据结构试验 顺序表
- 数据结构--顺序表
- 数据结构--顺序表
- 数据结构之顺序表
- 基本数据结构:顺序表
- lucene/solr 中Field类(域)的常用类型,以及Field属性解析
- 三方平台开发
- android 最快集成zXing二维码
- memcpy的用法总结
- 浅谈Js原型的理解
- 数据结构---顺序表
- CSS3 3D效果
- 大数据浪潮下的前端工程师
- 相对路径与绝对路径
- LDAP 网络用户账户
- LeetCode 347. Top K Frequent Elements
- http://blog.csdn.net/wangmuming/article/category/2167947Jenkins进阶系列
- El表达式
- 数列