早教吧作业答案频道 -->其他-->
c语言压缩文本文件求解答!写出来再加10分!48压缩文本文件成绩:5/折扣:0.8背景:压缩是一种有效的减小数据量的方法,目前已经被广泛应用于各种类型的信息系统之中。一种
题目详情
c语言压缩文本文件 求解答!写出来再加10分!
48 压缩文本文件
成绩: 5 / 折扣: 0.8
背景:
压缩是一种有效的减小数据量的方法,目前已经被广泛应用于各种类型的信息系统之中。
一种压缩文本文件的方法如下:
1. 原始文本文件中的非字母的字符,直接拷贝到压缩文件中;
2. 原始文件中的词(全部由字母组成),如果是第一次出现,则将该词加入到一个词的列表中,并拷贝到压缩文件中;否则该词不拷贝到压缩文件中,而是将该词在词的列表中的位置拷贝到压缩文件中。
3. 词的列表的起始位置为 1 。 词的定义为文本中由大小写字母组成的最大序列。大写字母和小写字母认为是不同的字母,即 abc 和 Abc 是不同的词。词的例子如下: * x-ray 包括两个词 x 和 ray * mary's 包括两个词 mary 和 s * a c-Dec 包括三个词 a 和 c 和 Dec 编写一个程序,输入为一组字符串,输出为压缩后的文本。
输入:
输入为一段文本,你可以假设输入中不会出现数字、每行的长度不会超过 80 个字符,并且输入文本的大小不会超过 10M。
输出:
压缩后的文本。
测试输入
1.Please, please do it--it would please Mary very,↵
2.very much.↵
3.↵
4.Thanks↵
期待输出
1.Please, please do it--4 would 2 Mary very,↵
2.7 much.↵
3.↵
4.Thanks↵
测试输入1.Background↵
2.↵
3.Given an m by n grid of letters and a list of words, find the location in the↵
4.grid at which the word can be found.↵
5.↵
6.A word matches a straight, uninterrupted line of letters in the grid. A word↵
7.can match the letters in the grid regardless of case (i.e., upper- and↵
8.lowercase letters are to be treated as the same). The matching can be done in↵
9.any of the eight horizontal, vertical, or diagonal directions through the grid.↵
10.↵
11.Input↵
12.↵
13.The input begins with a single positive integer on a line by itself indicating↵
14.the number of cases, followed by a blank line. There is also a blank line↵
15.between each two consecutive cases.↵
16.↵
17.Each case begins with a pair of integers m followed by n on a single line,↵
18.where m, n in decimal notation. The next m lines contain n letters each,↵
19.representing the grid of letters where the words must be found. The letters↵
20.in the grid may be in upper- or lowercase. Following the grid of letters,↵
21.another integer k appears on a line by itself (k). The next k lines of inp↵
期待输出的形式和第一个测试用例一样
48 压缩文本文件
成绩: 5 / 折扣: 0.8
背景:
压缩是一种有效的减小数据量的方法,目前已经被广泛应用于各种类型的信息系统之中。
一种压缩文本文件的方法如下:
1. 原始文本文件中的非字母的字符,直接拷贝到压缩文件中;
2. 原始文件中的词(全部由字母组成),如果是第一次出现,则将该词加入到一个词的列表中,并拷贝到压缩文件中;否则该词不拷贝到压缩文件中,而是将该词在词的列表中的位置拷贝到压缩文件中。
3. 词的列表的起始位置为 1 。 词的定义为文本中由大小写字母组成的最大序列。大写字母和小写字母认为是不同的字母,即 abc 和 Abc 是不同的词。词的例子如下: * x-ray 包括两个词 x 和 ray * mary's 包括两个词 mary 和 s * a c-Dec 包括三个词 a 和 c 和 Dec 编写一个程序,输入为一组字符串,输出为压缩后的文本。
输入:
输入为一段文本,你可以假设输入中不会出现数字、每行的长度不会超过 80 个字符,并且输入文本的大小不会超过 10M。
输出:
压缩后的文本。
测试输入
1.Please, please do it--it would please Mary very,↵
2.very much.↵
3.↵
4.Thanks↵
期待输出
1.Please, please do it--4 would 2 Mary very,↵
2.7 much.↵
3.↵
4.Thanks↵
测试输入1.Background↵
2.↵
3.Given an m by n grid of letters and a list of words, find the location in the↵
4.grid at which the word can be found.↵
5.↵
6.A word matches a straight, uninterrupted line of letters in the grid. A word↵
7.can match the letters in the grid regardless of case (i.e., upper- and↵
8.lowercase letters are to be treated as the same). The matching can be done in↵
9.any of the eight horizontal, vertical, or diagonal directions through the grid.↵
10.↵
11.Input↵
12.↵
13.The input begins with a single positive integer on a line by itself indicating↵
14.the number of cases, followed by a blank line. There is also a blank line↵
15.between each two consecutive cases.↵
16.↵
17.Each case begins with a pair of integers m followed by n on a single line,↵
18.where m, n in decimal notation. The next m lines contain n letters each,↵
19.representing the grid of letters where the words must be found. The letters↵
20.in the grid may be in upper- or lowercase. Following the grid of letters,↵
21.another integer k appears on a line by itself (k). The next k lines of inp↵
期待输出的形式和第一个测试用例一样
▼优质解答
答案和解析
可以考虑用一个map 键值对 来存放 的首次出现单词,一个单词对应一个序号
然后一行一行进行读取,对每一行里的字符 只要不是字母 就截取来 和 map、中已有的单词进行比较 重复的 就取出序号代替 不重复的 放进map
这样就好了
你需要一个获取单词的函数 一个压缩单词的函数 一个比较单词的函数
把这3个函数做出来 你的程序 大致就好了
这个 你自己想比较好 和简单其实
然后一行一行进行读取,对每一行里的字符 只要不是字母 就截取来 和 map、中已有的单词进行比较 重复的 就取出序号代替 不重复的 放进map
这样就好了
你需要一个获取单词的函数 一个压缩单词的函数 一个比较单词的函数
把这3个函数做出来 你的程序 大致就好了
这个 你自己想比较好 和简单其实
看了c语言压缩文本文件求解答!写出...的网友还看了以下:
4×100米接力跑中,甲队的成绩是39.2秒,乙队的成绩是43.8秒.甲队队员的平均成绩比乙队队员 2020-05-17 …
小明参加了某电视台招聘记者的三项素质测试,成绩如下:采访写作70分,计算机操作60分,创意设计88 2020-08-03 …
下面是五年级一班女生的跳远成绩记录单(单位:米)2.52.352.53.052.52.52.82.5 2020-10-30 …
下面是五年级1班女生的跳远成绩记录单(单位:米).2.52.32.53.22.82.62.82.92 2020-10-30 …
小明在上体育课时,侧立定跳远成绩是2.2m,测跳远成绩是4.5m,为什么两次成绩不小明在上体育课时, 2020-10-30 …
15.从正方体ABCD-A1B1C1D1的8个顶点中选取4个,作为四面体的顶点,可得到的不同四面体的 2020-11-06 …
直接写出得数.0.5×4÷0.5×4=4.2-4.2×0.5=1.2÷4×1.2÷4=6.3+6.3 2020-11-19 …
直接写得数80×5=7×40=600×6=25÷5=48÷8=54÷8=400×8=7×10=300 2020-11-19 …
直接写得数.1-0.99=3.6÷0.4=8.2+2.8=14×0.25×4=8.8+1.12=2. 2020-11-19 …
中位数和众数的问题五(3)班同学准备在两名女学生中选一名参加投篮比赛,下面是她们8次投篮的成绩记录( 2020-12-23 …