2019 Asia 网络赛 Yinchaun C

本文深入探讨了使用C++实现的一种字符串加密算法,通过调整字母的位置来达到加密的效果。文章详细介绍了算法的实现过程,包括如何计算偏移量、进行字符位移以及最终输出加密后的字符串。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <stack>
#include <stdlib.h>
#include <stdio.h>

#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define l(x) x<<1
#define r(x) x<<1|1
#define ms(a,b) memset(a,b,sizeof(a))

using namespace std;

int x;
int n, m;
char str1[500], str2[500], str3[500];
int len;

int main() {
	scanf("%d", &x);
	for (int i = 1; i <= x; i++) {
		scanf("%d%d", &n,&m);
		scanf("%s%s%s", str1, str2,str3);

		len = ((str2[0] - str1[0]) % 26 + 26) % 26;
		len = 26 - len;
		for (int i = 0; i < m; i++) {
			str3[i] = (str3[i]-'A' + len) % 26+'A';
		}
		printf("Case #%d: %s\n",i, str3);
	}

	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值