BensonQAQ @ 2020-10-11 13:56:46
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n;
string s;
cin>>n>>s;
for(int i=0;i<s.size();i++)
{
s[i]+=n;
while(s[i]>122)
s[i]-=26;
}
cout<<s;
return 0;
}
26 qwertyuiopasdfghjklzxcvbnm
qwertyuiopasdfghjklzxcvbnm
26 q=113
113+26=139(s[i]>122)-26=113
by BensonQAQ @ 2020-10-11 14:00:48
https://cdn.luogu.com.cn/upload/image_hosting/t0j2zryx.png
by Wu_Ren @ 2020-10-11 15:01:11
while(s[i]>122)
改成
while(s[i]>122||s[i]<0)
by BensonQAQ @ 2020-10-11 15:36:09
@Wu_Ren 谢谢
by tian_chen @ 2020-11-05 15:53:59
为什么.....