張懌宸Eason @ 2021-04-25 22:14:31
#include<bits/stdc++.h>
using namespace std;
char s[1000];
long long k;
int main()
{
cin>>k>>s;
for(int i=0;s[i];++i){
s[i]+=k;
if(s[i]>'z') s[i]+=-26;
}
cout<<s<<endl;
return 0;
}
by qqqqq111 @ 2021-04-25 22:20:05
s的Ascll可能会超过ascll码的范围
by qqqqq111 @ 2021-04-25 22:21:12
@張懌宸Eason
by qqqqq111 @ 2021-04-25 22:21:44
而且k可能会超过100,需要将k %26
by 張懌宸Eason @ 2021-04-25 22:32:09
@qqqqq111 谢谢!!!
by qqqqq111 @ 2021-04-26 18:30:10
还没判断s[i]<'a'的情况呢
by coldy_rainy @ 2021-06-17 19:57:31
@qqqqq111 额额,题目中不是说“由不超过50个小写字母组成吗?”,这条代码多余了吧。
by qqqqq111 @ 2021-06-17 20:02:45
@penhaochen 不加会wa on #4