本关任务:对 26 个大写英文字母进行循环加密,输入一个大写英文字母(明文)和一个整数秘钥,输出用秘钥对该大写英文字母加密后的结果(密文)。
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
char c;
int step;
cin>>c>>step;
char d = c+step <= 'Z' ? c+step : c+step - 26;
cout << d;
return 0;
}
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
char c;
int step;
cin>>c>>step;
char d = (c - 'A' + step) % 26 + 'A';
cout << d;
return 0;
}