数据结构之线性表
2016-06-02 17:12
465 查看
数据结构之线性表
#include <stdio.h>#include <stdlib.h>
#define kMAXListSize 1024
typedef struct
{
int data[kMAXListSize];
int count;
}LinearList;
LinearList *createLinearList()
{
LinearList *list = (LinearList *)malloc(sizeof(LinearList));
list->count =0;
return list;
}
void appendNote(LinearList *list,int data)
{
int count = list->count;
if(count <=kMAXListSize ) {
list->data[count] = data;
list->count ++;
}
}
void appendNoteByPointer(LinearList *list,int data)
{
int count = list->count;
if(count <=kMAXListSize)
{
list->data[count] = data
}
}
int deleteNote(LinearList *list,int pos)
{
int count = list->count;
if( pos < count && pos >0) {
for (int i = pos; i < count; i ++) {
list->data[i] = list->data[i +1];
}
list->count --;
return1;
}
return0;
}
void updateNote(LinearList *list,int pos,
int data)
{
int count = list->count;
if(pos <0 || pos >= count)
return;
list->data[pos] = data;
}
int findNote(LinearList *list,int pos)
{
int count = list->count;
if(pos <0 || pos >= count)
return0;
return list->data[pos];
}
int isEmpty(LinearList *list)
{
return list->count ==0;
}
void myPrint(LinearList *list)
{
for (int i =0; i < list->count;
i ++) {
printf("data[%d] = %d \n", i, list->data[i]);
}
}
相关文章推荐
- 数据结构之线性链表
- 二分查找总结
- LabVIEW中实现链表、树等数据结构
- 经典数据结构与算法(五)-哈希表
- 数据结构3.双端链表
- 数据结构学习笔记之模板栈
- 软件设计师数据结构之线性结构复习小结
- POJ3264 Balanced Lineup(线段树静态)
- [数据结构与算法分析]最大子序列和问题 -学习笔记
- 数据结构与算法:数组(一)
- 多叉树的构建及遍历
- Inverted File Index 文件倒排索引 课件理解与习题解
- Redis数据结构命令之String
- java数据结构之单链表应用之一元多项式求和
- java数据结构之顺序表应用之大整数求和
- 实现单向链表节点删除
- 数据结构—哈夫曼树
- Codeforces418D Big Problems for Organizers
- 改进的插入排序算法
- 白话篇:零姿势实现排序二叉树的建立与查找