TOj 3070. Encryption【水题】

3070. Encryption
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 2882 Accepted Runs: 1310



You must have heard of an ancient encryption called Caesar cipher or 'shift cipher'. That is, given the plaintext and a number D, you should replace every character c in the plaintext with another character which is D 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

2
tjucs 1
abcd 0

Sample Output

ukvdt
abcd



密码加密的一种方式,直接模拟就行了,注意取余


#include<bits/stdc++.h>
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		char x[1005];int n;
		scanf("%s%d",x,&n);
		for(int i=0;x[i]!=0;++i)
		{
			x[i]-='a';
			x[i]=(x[i]+n)%26;
			x[i]+='a';
			printf("%c",x[i]);
		}
		printf("\n");
	}
	return 0;
}	


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值