THEONE_k @ 2024-08-08 09:09:04
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s;
cin>>n>>s;
for(int i=0;i<s.length();i++)
{
s[i]=s[i]+n;
if(s[i]>'z')
{
s[i]='a'+s[i]%'z'-1;
}
}
cout<<s;
return 0;
}
in
26
qwertyuiopasdfghjklzxcvbnm
out
qwertyuiopasdfghjklzxcvbnm
我的输出
嫅e寧搹儔奱峝€亗剠啍抍恇垏
明明大于z的时候循环到a开始了
by lovely_codecat @ 2024-08-08 09:14:59
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s;
cin>>n>>s;
for(int i=0;i<s.length();i++)
{
if(s[i]+n>'z')
{
s[i]=s[i]-26+n;
}
else s[i]+=n;
}
cout<<s;
return 0;
}
字符只有126个,如果
by THEONE_k @ 2024-08-08 09:38:22
@lovely_codecat 感谢