3. 文本编辑
201
• 文本可以看成是一个
字符串 ( 文本串 ). 页 m a i n ( ) { ↵
是文本串的字串 , 行 f l o a t a , b ,
是页的字串 . m a x ; ↵ s c a
文本 : n f ( “ %f , %f ”
main() { ,& a , & b ) ; ↵
float a, b,max; i f a > b m
scanf(“%f,%f”, &a, &b); a x = a ; e l s e
if a>b max=a; m a x = b ; ↵ } ; ↵
else max=b;
};
9. 文本编辑程序的实现
2. 串的基本操作 bo4-2.cpp
void InitString(HString &T); // 串的初始化
void StrAssign(HString &T,char *chars) ; // 生成一
个其值等于串常量 c ha rs 的串 T
int Index(HString S, HString T, int pos);
//T 为非空子串 . 若主串 S 中第 p o s 个字符后
存在与 T 相等的子串 , 则返回第一个这样的子串
在 S 中的位置 ; 否则返回 0
10. 文本编辑程序的实现
2. 串的基本操作 bo4-2.cpp
Status StrInsert(HString &S,int pos, HString T)// 在
串 S 的第 p o s 个字符前插入串 T
Status StrDelete(HString &S,int pos, int len) ; // 从
串 S 中删除第 p o s 个字符起长度为 le n 的子串
...
27. 如何建立索引表
重复下列操作直至文件结束:
(2) 从书目文件中读入一个书目串
BookInfo.txt
005 buf
Computer Data Structures 005 Computer Data
010 Structures
Introduction to Data
Structures
023 从书目文件中读取 1
Fundamentals of Data
Structures 行信息到缓存 b uf
034
The Design and Analysis of
Computer
...
28. 如何建立索引表 wdlist
[0] Computer
(2) 从书目串中提取 Data
[1]
所有关键词插入
[2] Structure
词表
buf
005 Computer
Data Structures ... ...
BookNo 005
[9]
last 3
当前书号对应的关键词
表
30. 如何建立索引表
提取关键词的处理:
顺序扫描书目单,分词,剔除常
用词,为此设定“停用词表”。将确定为
关键词的词汇置于临时词表中。
书名: The Design and Analysis of Computer algorithms
剔除: The and of
关键词: Design Analysis Computer Algorithm
32. 如何建立索引表 wdlist
[0] design
•数据结构 [1] Analysis
词表: 线性表,存放关键 [2] Computer
词 [3] Algorithms
Typ e d e f s truc t{ ... ...
c ha r * ite m[ ] ; // 字符
串的数组 [9]
int la s t ; // 词表的长度 last 4
} Wo rld L is tTyp e ; //
词表类型(顺序表)