You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
595 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main() {
cin >> n >> s;
//遍历每个字符
for (int i = 0; i < s.size(); i++) {
//s[i]遍历到的字符s[i]+n就是目标字符但是有可能是超过了'z'的
int c = s[i] + n;
//超过了z该怎么办呢
if (c > 'z') c = c - 'z' - 1 + 'a';
// if (c > 'z') c = c - 26;
//重新的放回到原来的数组位置上,生成新的字符串
s[i] = c;
//s[i] = (char) c;
}
cout << s << endl;
return 0;
}