数据结构(C语言版)
第四章P86-89 建立词索引表
参考链接 1:http://blog.chinaunix.net/uid-25996097-id-4299764.html?utm_source=jiancool
本程序的问题:
1 书籍索引不是按顺序排列;
2 int ExtractKeyWord(WordListType *wdlist)函数对文件最后一行的处理还是有问题,因为前几行行尾都有回车,和最后一行情况不同,这就导致booklist.txt中几行的长度不一样,所以链接1中的词汇提取是先提取到一个新数组中,再存入词表,有点累,没有再处理了。
(总要不停的考虑指针到底指到哪儿了,脑壳有点疼)
booklist.h
#ifndef BOOKLIST_H
#define BOOKLIST_H
#define MaxKeyNum 20
#define MaxLineLen 100
#define MaxWordNum 10
#define MaxKeyWordLen 10
#define OK 1
#define FALSE 0
typedef int Status;
typedef int ElemType;
typedef struct{
char item[MaxWordNum][MaxKeyWordLen];
int lenth;
}WordListType;
typedef struct LinkList{
int BookNo;
struct LinkList *next;
}LinkList;
typedef struct{
char key[20];
LinkList bnolist;
}IdxTermType;
typedef struct{
IdxTermType item[MaxKeyNum];
int len;
}IdxListType;
#endif // BOOKLIST_H
typedef struct{
char key[20];
LinkList bnolist;
}IdxTermType;
开始写成char