字符串处理,重点不在于解密,因为给出的对应字符串天然就是一个数组。关键在于整行读入的技巧,而之前就要吃掉多余的换行符。另外复制输入数据时,要注意不要把多余的空格弄进去。
Run Time: 0sec
Run Memory: 312KB
Code Length: 429Bytes
Submit Time: 2012-02-20 13:50:03
// Problem#: 1624
// Submission#: 1212325
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
int main()
{
int N, n, i;
string s, r;
cin >> N;
for ( n = 1; n <= N; n++ ) {
getchar();
getline( cin, r );
cin >> s;
for ( i = 0; i < r.size(); i++ ) {
if ( r[ i ] != ' ' )
r[ i ] = s[ r[ i ] - 'A' ];
}
cout << n << " " << r << endl;
}
return 0;
}