霹雳搅屎棍 @ 2018-10-02 19:45:28
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
char s[55],ans[55];
int main(int argc, char** argv) {
scanf("%d",&n);
scanf("%s",s);
int len=strlen(s);
for(int i=0;i<len;i++){
ans[i]=s[i]+n;
if(ans[i]>122)
ans[i]-=26;
}
printf("%s",ans);
return 0;
}
第三和第四挂了
26
qwertyuiopasdfghjklzxcvbnm
by LCuter @ 2018-10-02 19:52:09
n有可能大于26(?)
by LCuter @ 2018-10-02 19:53:37
@霹雳搅屎棍 后移是加完你直接取模26即可,但是要把字母减去'a'最后输出再家回去
by 霹雳搅屎棍 @ 2018-10-02 19:54:49
@常暗踏阴 过了,多谢