键索数组引符号表
来源:互联网 发布:linux 映射内网端口 编辑:程序博客网 时间:2024/05/21 16:59
键索数组引符号表使用数组模拟符号表
使用固定数组大小,为了便于调试。
代码是参照c算法的书上
typedef int Key;
typedef int Item;
#define ITEMNULL 0
Item st[10];
int M;
#define key(A) (A)
void STinit(int n)
{
M = n;
}
int STcount()
{
int count =0;
for (int i =0;i <M;++i)
{
if (st[i] !=ITEMNULL)
{
count +=1;
}
}
return count;
}
void STinsert(Item aItem)
{
st[key(aItem)] = aItem;
}
Item STsearch(Key aKey)
{
returnst[aKey];
}
void STdelete(Item aItem)
{
st[key(aItem)] =ITEMNULL;
}
Item STselect(int k)
{
int i =0;
Item tempItem =ITEMNULL;
for (;i <M; ++i)
{
if (st[i] !=ITEMNULL)
{
if (k-- ==0)
{
tempItem =st[i];
break;
}
}
}
return tempItem;
}
void STsort(void (*visit)(Item))
{
for (int i =0;i <M;++i)
{
if (st[i] !=ITEMNULL)
{
visit(st[i]);
}
}
}
- 键索数组引符号表
- 有序数组实现符号表
- 使用数组模拟符号表的程序
- 符号&数组名&变量
- python数组符号重载
- 数组添加符号输出
- 符号表以及在有序数组中的二分查找
- 有序符号表(数组实现,JAVA,算法(四),二分法)
- matlab 如何定义符号数组
- 符号表
- 符号表
- 符号表
- 符号表
- 符号表
- 符号表
- 符号表
- 符号表
- 符号表
- 澳洲品牌SONIQ声光登入中国 多重量级商品发布
- spring整合hibernate(注解、xml)applicationContext.xml配置
- 表视图的分组分区和索引分区
- <四> cocos2dx动画常见22种特效
- jquery使用自己获得的值来拼凑id
- 键索数组引符号表
- 第4讲 初步尝试编写shell脚本
- HTML5+CSS3学习笔记(一) 概述
- 克服敲代码之“痒”
- .net实现验证码功能
- 嵌入式 hi3518c平台uboot中start.s小结
- 萨的卡斯比
- UVa 11437 Triangle Fun(几何)
- 一些基本算法的递归实现