Sicily 1624. Cryptoquote

Time Limit: 1 secs, Memory Limit: 32 MB

Description

A cryptoquote is a simple encoded message where one letter is simply replaced by another throughout the message. For example:

Encoded: HPC PJVYMIY
Decoded: ACM CONTEST

In the example above, H=A, P=C, C=M, J=O, V=N, Y=T, M=E and I=S. For this problem, you will decode messages.

Input

The first line of input contains a single integer N , (1≤N≤1000) which is the number of data sets that follow. Each data set consists of two lines of input. The first line is the encoded message. The second line is a 26 character string of upper case letters giving the character mapping for each letter of the alphabet: the first character gives the mapping for A, the second for B and so on. Only upper case letters will be used. Spaces may appear in the encoded message, and should be preserved in the output string.

Output

For each data set, you should generate one line of output with the following values: The data set number as a decimal integer (start counting at one), a space and the decoded message.

Sample Input

2
HPC PJVYMIY
BLMRGJIASOPZEFDCKWYHUNXQTV
FDY GAI BG UKMY
KIMHOTSQYRLCUZPAGWJNBVDXEF

Sample Output

1 ACM CONTEST
2 THE SKY IS BLUE


(∩_∩) Just do it!

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str, strp;
    int T;
    cin >> T;
    for (int i = 1; i <= T; i++)
    {
        cin.get(); // This is very important! Don't forget it!
        getline(cin, str);
        cin >> strp;
        cout << i << " ";
        for (int j = 0; j < str.size(); j++)
            if (str[j] >= 'A' && str[j] <= 'Z')
                cout << strp[str[j] - 'A'];
            else
                cout << str[j];
        cout << endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值