没有合适的资源?快使用搜索试试~ 我知道了~
建立词索引表(数据结构,串的应用)
5星 · 超过95%的资源 需积分: 25 68 下载量 192 浏览量
2010-11-15
16:37:59
上传
评论 4
收藏 9KB TXT 举报
温馨提示
试读
12页
这个是严奶奶《数据结构》里面程序的实现,程序自己看,废话不多说
资源推荐
资源详情
资源评论
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define MaxBookNum 1000 //假设只对1000本书建索引表
#define MaxKeyNum 2500 //索引表的最大容量
#define MaxLineLen 500 //书目串的最大长度
#define MaxWordNum 10 //词表的最大容量
typedef struct{
char *item[MaxKeyNum]; //字符串的数组
int last; //词表的长度
}WordListType; //词表类型(顺序表)
typedef struct LNode{ //存放书号的链表
int data[3];
struct LNode *next;
}LNode, *LinkList;
typedef struct{ //存放关键词的串
char *ch;
int length;
}HString;
typedef struct{
HString *key;
LinkList bnolist;
}IdxTermType; //索引项类型
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define MaxBookNum 1000 //假设只对1000本书建索引表
#define MaxKeyNum 2500 //索引表的最大容量
#define MaxLineLen 500 //书目串的最大长度
#define MaxWordNum 10 //词表的最大容量
typedef struct{
char *item[MaxKeyNum]; //字符串的数组
int last; //词表的长度
}WordListType; //词表类型(顺序表)
typedef struct LNode{ //存放书号的链表
int data[3];
struct LNode *next;
}LNode, *LinkList;
typedef struct{ //存放关键词的串
char *ch;
int length;
}HString;
typedef struct{
HString *key;
LinkList bnolist;
}IdxTermType; //索引项类型
typedef struct{
IdxTermType item[MaxKeyNum + 1];
int last;
}IdxListType; //索引表类型(有序表)
char *buf; //书目串缓冲区
WordListType wdlist; //词表
int i; //无重复的关键字个数
int b; //保留i的前一次变换的值
int v;
char *com[10] = {"and","a","an","the","a","an","to","of"};
IdxListType *InitIdxList(IdxListType *idxlist)
//初始化操作,置索引表idxlist为空表,且在idxlist.item[0]设一空串。
{
idxlist = (IdxListType *)malloc(sizeof(IdxListType));
if(idxlist == NULL)
{
printf("ERROR――1!");
exit(-1);
}
idxlist->item[0].key = (HString *)malloc(sizeof(HString));
idxlist->item[0].bnolist = (LinkList)malloc(sizeof(LNode));
idxlist->item[0].key->ch = NULL;
idxlist->item[0].key->length = 0;
//idxlist->item[0].bnolist->data[3];
idxlist->item[0].bnolist->next = NULL;
idxlist->last = 0;
return idxlist;
}
IdxTermType item[MaxKeyNum + 1];
int last;
}IdxListType; //索引表类型(有序表)
char *buf; //书目串缓冲区
WordListType wdlist; //词表
int i; //无重复的关键字个数
int b; //保留i的前一次变换的值
int v;
char *com[10] = {"and","a","an","the","a","an","to","of"};
IdxListType *InitIdxList(IdxListType *idxlist)
//初始化操作,置索引表idxlist为空表,且在idxlist.item[0]设一空串。
{
idxlist = (IdxListType *)malloc(sizeof(IdxListType));
if(idxlist == NULL)
{
printf("ERROR――1!");
exit(-1);
}
idxlist->item[0].key = (HString *)malloc(sizeof(HString));
idxlist->item[0].bnolist = (LinkList)malloc(sizeof(LNode));
idxlist->item[0].key->ch = NULL;
idxlist->item[0].key->length = 0;
//idxlist->item[0].bnolist->data[3];
idxlist->item[0].bnolist->next = NULL;
idxlist->last = 0;
return idxlist;
}
剩余11页未读,继续阅读
资源评论
- 「已注销」2013-12-07挺好用的。
- qq_235444372015-11-10程序报错了
- qq_205452892014-09-16内容不错,值得参考,代码挺详细的
- chenkun11092015-02-02注释写的很详细,谢谢。
我的职业是看店铺的
- 粉丝: 152
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功