Accelerated-c++-置换索引

来源:互联网 发布:可以赚钱的app软件 编辑:程序博客网 时间:2024/05/20 01:47

问题

第五章练习题5-1.
设计和实现一个程序以产生一个置换索引。
在一个置换索引当中,每个短语都是以这个短语的每一个单词作为索引的(类似倒排,内容做索引)。因此,假如有如下的输入:

The quick brown fox
jumped over the fence
得到如下的输出:
The quick \t brown fox
jumped over the \t fence
The quick brown \t fox
\t jumped over the fence
jumped \t over the fence
The \t quick brown fox
jumped over \t the fence
\t The quick brown fox

这个输出有一点摸不着头脑!

思路

这个题用的是书本给出的思路。
1.产生轮转集合
The quick brown fox (The是置换索引)
quick brown fox The(quick)
brown fox The quick(brown)
fox The quick brown(fox)
jumped over the fence(jumped)
over the fence jumped(over)
the fence jumped over(the)
fence jumped over the(fence)

2.排序。
对字符串进行排序,但是排序的一句是置换索引。
排序之后的结果为:
brown fox The quick(brown)
fence jumped over the(fence)
fox The quick brown(fox)
jumped over the fence(jumped)
over the fence jumped(over)
quick brown fox The(quick)
the fence jumped over(the)
The quick brown fox(The)

3.值置换索引开始输出,直到当前串的第一个单词,用\t分割
brown fox \t The quick
fence \t jumped over the
fox \t The quick brown
jumped over the fence \t
over the fence \t jumped
quick brown fox \t The
the fence \t jumped over
The quick brown fox \t

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 车凹陷漏底漆了怎么办 燕子窝掉下来了怎么办 文科没考上一本怎么办 学校午休小学孩子吵闹怎么办 老鼠死在空调里怎么办 公务员老公四十岁想辞职怎么办 打胎5次又怀孕怎么办 墙纸颜色太淡了怎么办 皮子腺囊肿有点疼痛怎么办 地板颜色选浅了怎么办 地板买的太暗了怎么办 木地板贴好后发现颜色不好看怎么办 鞋上鞋扣老是开怎么办 虚拟机的win10蓝屏重启怎么办 fs免拆模板专利怎么办 新买的床咯吱响怎么办 实木床一动就响怎么办 cad图纸是斜的怎么办 老房子土墙腻子老掉怎么办 生完孩子子宫大怎么办 刚开的店没人怎么办 刚开业的店没人怎么办 美容店没人进店怎么办 新店开业招不到营业员怎么办 无意开通了花呗怎么办? 花呗灰色用不了怎么办 花呗逾期用不了怎么办 店铺花呗关闭了怎么办 花呗无法使用了怎么办 借呗自动关闭了怎么办 蚂蚁花呗无法开通怎么办 花呗本月还不了怎么办 蚂蚁借呗没钱还怎么办 淘宝账号被限制登录怎么办 辱骂买家被投诉骚扰怎么办 淘宝卖家骚扰买家怎么办 被淘宝卖家电话骚扰怎么办 闲鱼卖东西买家退货运费怎么办 淘宝被恶意拍单怎么办 炒作信用度评价被删除怎么办 删除淘宝评价之后卖家不返现怎么办