TOJ 3070. Encryption

来源:互联网 发布:手机变平板软件 编辑:程序博客网 时间:2024/05/17 08:21

数字转ACS||码的方法为+'0';

You must have heard of an ancient encryption called Caesar cipher or 'shift cipher'. That is, given the plaintext and a numberD, you should replace every character c in the plaintext with another character which isD places after c in the alphabet. For example, if D = 2, you should replace 'a' with 'c', replace 'b' with 'd', ... replace 'y' with 'a', and replace 'z' with 'b'.

Given the plaintext and D, you should output the cipher text.

Input

The first line is an integer T, the number of test cases. Then T cases follows.

Each case contains only one line, consists of the plaintext and the number D, separated by a space. You can assume there are only lower case letters in the plaintext, and the length is no more than 100. 0 ≤D < 26.

Output

Output one line for each test case, indicating the cipher text.

Sample Input

2tjucs 1abcd 0

Sample Output

ukvdtabcd
#include<iostream>#include<string>using namespace std;int main(){string s="abcdefghijklmnopqrstuvwxyz";string c;char b;int n,d,l,j;cin>>n;while(n--){cin>>c>>d;//cout<<c<<endl;//cout<<d<<endl;l=c.length();j=0;for(int i=0;i<l;i++){int k=c[i]-'0'+d;//cout<<k<<" ";if(k>74)k=k-74+48;b=k+'0';cout<<b;}cout<<endl;}return 0;}


0 0