as_lky @ 2019-08-03 15:47:24
using namespace std; char s[55]; int main() { int m; cin>>m; cin>>s; int l=strlen(s); for(int i=0;i<=l-1;i++) { if(int(s[i])+m>=123) { s[i]=char((int(s[i])+m-122)%26+96); break; } else s[i]=char(int(s[i])+m); }
cout<<s;
return 0;
}
by hanzizhou @ 2019-08-03 15:50:40
?
by __lOi_iOl__ @ 2019-08-03 15:51:07
希望更丰富的展现?使用Markdown
by as_lky @ 2019-08-03 15:53:11
把break改成continue后,还是只有八十分 神犇救救我啊!
by RainFestival @ 2019-08-03 15:53:39
@lky6666666 希望更丰富的展现?使用Markdown
by shixiayuan_2022 @ 2019-08-03 16:22:41
@lky6666666
给你个数据
26
z
对于z,计算错了QAQ
更改后:
#include<bits/stdc++.h>
using namespace std;
char s[55];
int main()
{
int m;
cin>>m;
cin>>s;
int l=strlen(s);
for(int i=0;i<=l-1;i++)
{
if(int(s[i])+m>=123)
{
s[i]=char((int(s[i])+m-122)%26+96);
if(s[i]=='`') s[i]='z';
}
else s[i]=char(int(s[i])+m);
}
cout<<s;
return 0;
}
by as_lky @ 2019-08-05 20:10:25
谢谢shixiayuan_2022!!