Crypto Columns
来源:互联网 发布:php课程表页面代码 编辑:程序博客网 时间:2024/06/05 03:58
1036. Crypto Columns
MEETME
BYTHEO
LDOAKT
REENTH
Here, we've padded the message with NTH. Now the message is printed out by columns, but the columns are printed in the order determined by the letters in the keyword. Since A is the letter of the keyword that comes first in the alphabet, column 2 is printed first. The next letter, B, occurs twice. In the case of a tie like this we print the columns leftmost first, so we print column 1, then column 4. This continues, printing the remaining columns in order 5, 3 and finally 6. So, the order the columns of the grid are printed would be 2, 1, 4, 5, 3, 6, in this case. This output is called the ciphertext, which in this example would be EYDEMBLRTHANMEKTETOEEOTH. Your job will be to recover the plaintext when given the keyword and the ciphertext.
There will be multiple input sets. Each set will be 2 input lines. The first input line will hold the keyword, which will be no longer than 10 characters and will consist of all uppercase letters. The second line will be the ciphertext, which will be no longer than 100 characters and will consist of all uppercase letters. The keyword THEEND indicates end of input, in which case there will be no ciphertext to follow.
BATBOYEYDEMBLRTHANMEKTETOEEOTHHUMDINGEIAAHEBXOIFWEHRXONNAALRSUMNREDEXCTLFTVEXPEDARTAXNAARYIEXTHEEND
MEETMEBYTHEOLDOAKTREENTHONCEUPONATIMEINALANDFARFARAWAYTHERELIVEDTHREEBEARSXXXXXX
题目描述:二维数组转换,根据给出关键词的字母顺序,逆转组合出原来的字符串。
分析:
根据字符串A,可以知道加密时先取哪一列,再取哪一列,于是可以把字符串按顺序填回到矩阵中,最后按从上到下的顺序得到字符串B。
关键词字符串找最小字母:每次比较ASCII值,找到最小后,将其填充为一个比Z还大的字符,以后再对这个字符串找最小的时候,不会再找回这个位置。
#include<iostream>#include<string>char note[11][11];using namespace std;int min(string k){ int be=-1; int min='Z'+1; int note; for(int i=0;i<k.size();i++) { if(k[i]<min) { min=k[i]; be=i; } } return be;}int main(){ string key; string s; while(cin>>key) { if(key=="THEEND") return 0; cin>>s; int len1=key.size(); int len2=s.size(); int line; line=len2/len1; int less; int a=0; for(int x=0;x<len1;x++) { less=min(key); key[less]='a'; for(int i=0;i<line;i++) { note[i][less]=s[a]; a++; } } for(int i=0;i<line;i++) { for(int j=0;j<len1;j++) { cout<<note[i][j]; } } cout<<endl;}//system("pause");return 0;}
- Crypto Columns
- 1036. Crypto Columns
- Sicily 1036. Crypto Columns
- sicily1036. Crypto Columns
- sicily--1036. Crypto Columns
- poj 1617 Crypto Columns
- Crypto Columns加密列
- 1036. Crypto Columns
- Sicily.1036. Crypto Columns
- Sicily 1036. Crypto Columns
- sicily 1036. Crypto Columns
- SOJ 1036. Crypto Columns
- Sicily 1036. Crypto Columns
- POJ 1617 Crypto Columns
- 1036[Crypto Columns]
- sicily 1036.Crypto Columns
- Sicily 1036. Crypto Columns
- Sicily 1036. Crypto Columns
- 推荐十款来自极客标签的超棒前端特效[第十三期]
- full case与parallel case
- Linux简单介绍
- Flex中的拖动技术
- excel双色行显示
- Crypto Columns
- Impact使用
- ios 中的file not found的解决方法
- linux下的ldd
- 小for的Cocos2d-x学习笔记与感悟6之Action
- POJ 1047
- linux0.11中switch_to理解
- ML507的配置
- ExecutorService与Executors例子的简单剖析