单词索引表

读入一个英文的文档,然后建立一个单词引用索引表,也就是说,对于该文档中出现的所有单词,按照字母顺序进行排序,并且每个单词后面跟着它在文档中出现的行号。然后把这个索引表显示出来,同时保存在一个输出文件中。为了方便处理,假定文档长度不超过1000个字符,行数不超过20行,文档中的单词最长不超过20个字母。噪声单词,如“a, an, and, are, in, is, of, or, that, the, this, to, have”等单词不出现。

比如读入的是1.txt,则输出的单词索引表为2.txt

#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <cctype>//isalpha, isupper, tolower
#include <cstdlib>//exit

using namespace std;

static int s_lineNum = 1;//static line number 

int main(int argc, char *argv[])
{
	if (argc < 3)
	{
		cout << "usage: " << argv[0] << "infile" << "outfile" << endl;
		cout << "generate a word list from an English file,
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值