关于字符串编码和加密算法的一个问题,请问各位怎么采用C语言的实现?

Problem Description
Following the account of Jules Verne, a scrambled message written by the middle age alchemist Arne Saknussemm, and deciphered by professor Lidenbrock, started the incredible travel to the center of the Earth. The scrambling procedure used by Arne is alike the procedure given below.

  1. Take a non empty message M that contains letters from the English alphabet, digits, commas, dots, quotes (i.e. '), spaces and line breaks, and whose last character is different than space. For example, consider the following message whose translation reads "In Sneffels's crater descend brave traveler, and touch the center of the Earth".

In Sneffels craterem descende audasviator, et terrestre centrum attinges.

  1. Choose an integral number 0<K≤length(M) and add trailing spaces to M such that the length of the resulting message, say M', is the least multiple of K. For K=19 and the message above, where length(M)=74 (including the 8 spaces and the line break that M contains), two trailing spaces are added yielding the message M' with length(M')=76.

  2. Replace all the spaces from M' by the character _ (underscore) ; replace all the line breaks from M' by \ (backslash), and then reverse the message. In our case:

__.segnitta_murtnec_ertserret_te_,rotaiv\sadua_ednecsed_meretarc_sleffenS_nI

  1. Write the message that results from step 3 in a table with length(M')/K rows and K columns. The writing is column wise. For the given example, the message is written in a table with 76/19=4 rows and 19 columns as follows:
    [缺少图片]

  2. The strings of characters that correspond to the rows of the table are the fragments of the scrambled message. The 4 fragments of Arne's message given in step 1 are:

etmneet_t\udsmt_fS.narctrtria_edrrlen
_gtuerr
,asaneeasf_si_t_seeovdec_ecenI

Write a program that deciphers non empty messages scrambled as described. The length of a message, before scrambling, is at most 1000 characters, including spaces and line breaks.

Input
The program input is from a text file where each data set corresponds to a scrambled message. A data set starts with an integer n, that shows the number of fragments of the scrambled message, and continues with n strings of characters that designate the fragments, in the order they appear in the table from step 4 of the scrambling procedure. Input data are separated by white-spaces and terminate with an end of file.

Output
The deciphered message must be printed on the standard output, from the beginning of a line and must be followed by an empty line as shown in the input/output sample below.

Sample Input
4 etmneet_t\udsmt_fS
_gtuerr
,asaneeasf_
.narctrtria_edrrlen
si_t_seeovdec_ecenI
11 e n r e V _ s e l u J

Sample Output
In Sneffels craterem descende audas
viator, et terrestre centrum attinges.

Jules Verne

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

0
一个有关于字符串加密编码的方式的问题,采用C语言编码字符串的实现
0
字符串文本加密编码算法的实现过程,采用的是C语言的方式如何实现的?
0
字符串编码消除歧义的一个算法的问题的思路,如何使用C语言的技术实现?
0
日记的加密的算法,字符串编码如何利用C语言编程实现的呢
0
关于使用编码的算法对字符串进行加密的问题,怎么使用C程序的设计的思路怎么做
0
二进制对字符串的一个编码的算法的问题,怎么利用C语言程序代码的功能去实现的?
0
对字符串文本的一个编码的加密算法实现,怎么采用C程序的语言的代码编写的过程去实现的呢?
1
输入一个字符串,可以删除字符串s中的任意字符,剩下的字符串形成对称字符串,且该字符串为最长对称字符串
0
回文串,对于一个字符串的判断最长的算法,用C语言
1
NOI 上加密的病历单(字符串)的问题
1
关于字符串二维数组的问题
3
java 获取2个字符串中间所有的字符串
3
如何控制输入字符串为小写字母?
1
编写一个函数,将字符串S中所有子串t用字符串v
1
Java语言字符串和字符数组的关系和区别是什么?用eclipes的话,一般推荐用什么字符串形式
3
设计一个函数int stoi(char* str),将数字字符串str转换为一个整数。 main读取一个由数字字符构成的字符串放入数组,然后调用stoi函数得到转换后的整数并输出.
0
统计一个给定字符串中指定的字符出现的次数
4
Java语言悬赏问题,Java语言输入一个字符串,统计字符串里面字母、数字、符号的个数分别是多少
1
高分悬赏了Java语言编写,获取一个字符串里面最长的回文字符,具体要求如下
2
关于json字符串的问题