shipeiqian @ 2022-07-08 16:26:40
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;
char b[50];
string a;
cin >>n >>a;
if(n>=26){
for(int i=0;i<a.size();i++){
b[i]=a[i]+n%26;
}
}
else{
for(int i=0;i<a.size();i++){
b[i]=a[i]+n;
}
}
for(int i=0;i<a.size();i++){
cout <<b[i];
}
return 0;
}
by liangbowen @ 2022-07-08 16:29:15
简单的 hack:
输入
1
zzzzzz
您忘记对 b 数组搞取模了
by 拾然z @ 2022-07-08 16:30:08
@liangbowen %%%
by _cyle_King @ 2022-07-08 16:31:19
b[i]=a[i]+n;改成b[i]=(a[i]-'a'+n)%26+'a';改成
by _cyle_King @ 2022-07-08 16:32:20
两个都要改,没必要判断n>=26。