【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*ac-Dec包括三个词a和c和Dec编写一个程序,输入为一组字符串,输出为压缩后的文本。
输入:
输入为一段文本,你可以假设输入中不会出现数字、每行的长度不会超过80个字符,并且输入文本的大小不会超过10M。
输出:
压缩后的文本。
测试输入
1.Please,pleasedoit--itwouldpleaseMaryvery,↵
2.verymuch.↵
3.↵
4.Thanks↵
期待输出
1.Please,pleasedoit--4would2Maryvery,↵
2.7much.↵
3.↵
4.Thanks↵
测试输入1.Background↵
2.↵
3.Givenanmbyngridoflettersandalistofwords,findthelocationinthe↵
4.gridatwhichthewordcanbefound.↵
5.↵
6.Awordmatchesastraight,uninterruptedlineoflettersinthegrid.Aword↵
7.canmatchthelettersinthegridregardlessofcase(i.e.,upper-and↵
8.lowercaselettersaretobetreatedasthesame).Thematchingcanbedonein↵
9.anyoftheeighthorizontal,vertical,ordiagonaldirectionsthroughthegrid.↵
10.↵
11.Input↵
12.↵
13.Theinputbeginswithasinglepositiveintegeronalinebyitselfindicating↵
14.thenumberofcases,followedbyablankline.Thereisalsoablankline↵
15.betweeneachtwoconsecutivecases.↵
16.↵
17.Eachcasebeginswithapairofintegersmfollowedbynonasingleline,↵
18.wherem,nindecimalnotation.Thenextmlinescontainnletterseach,↵
19.representingthegridofletterswherethewordsmustbefound.Theletters↵
20.inthegridmaybeinupper-orlowercase.Followingthegridofletters,↵