taohuanyu @ 2024-12-15 10:22:21
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,len;
string s;
cin>>n;
cin>>s;
len=s.size();
for(int i=0;i<len;i++)
{
if(s[i]+n>'z') s[i]='a'+n-26;
else s[i]+=n;
}
cout<<s;
return 0;
}
by Ybll_ @ 2024-12-15 10:32:46
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string s;
cin>>n>>s;
for(int i=0;i<s.size();i++)
{
cout<<char((s[i]+n-'a')%26+'a');
}
return 0;
}
by hepingge10 @ 2024-12-15 10:34:35
改了一下第12行:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,len;
string s;
cin>>n;
cin>>s;
len=s.size();
for(int i=0;i<len;i++)
{
if(s[i]+n>'z')s[i]=n+s[i]-26;
else s[i]+=n;
}
cout<<s;
return 0;
}
by hepingge10 @ 2024-12-15 10:35:12
已AC