刘岱峻Adam @ 2021-06-16 20:18:45
#include <iostream>
#include <string>
using namespace std;
int main()
{
int key;
string s;
cin >> key >> s;
for (int i = 0; i < s.size(); i++)
{
if (s[i] == 'z')
{
s[i] = 'a';
s[i] += (key - 1);
}
s[i] += key;
}
cout << s;
}
by ud2_ @ 2021-06-16 20:23:44
@刘岱峻Adam 有考虑过 y
移动 2 位的情况吗?
by Leo2020 @ 2021-06-16 20:40:17
蒟蒻代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
string m;
cin >> m;
for(int j=0;j<m.size();j++)m[j]=(m[j]-'a'+n)%26+'a';
cout << m;
return 0;
}