wkm010202 @ 2016-12-02 16:36:26
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string s;
int n;
cin>>n>>s;
for(int i=0;i<s.size();i++)
{
s[i]=n%26+s[i];
if(s[i]>122) s[i]=s[i]-26;
}
cout<<s<<endl;
return 0;
}
by liuweixi20050805 @ 2016-12-04 18:20:51
我的似乎有点长:
#include<iostream>
#include<cstring>
using namespace std;
string jmm,zmm;
int n;
int main()
{
cin>>n>>jmm;
n=n%26;
zmm=jmm;
for(int i=0;i<=jmm.size()-1;i++)
{
for(int j=1;j<=n;j++)
{
if(jmm[i]=='z') jmm[i]='a';
else jmm[i]=jmm[i]+1;
}
zmm[i]=jmm[i];
}
cout<<zmm;
return 0;
}
by KesdiaelKen @ 2016-12-16 20:59:33
简单版:
#include<cstdio>
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int main()
{
int n;
string dr;
int len;
cin>>n>>dr;
len=dr.size();
for(int i=0;i<len;i++)
{
int jl=dr[i]-'a';
jl=(jl+n)%26;
dr[i]=jl+'a';
}
cout<<dr;
return 0;
}
by 百里亦守约_test @ 2016-12-27 16:19:08
#include<iostream>
#include<cstring>
using namespace std;
string st;
int n,s;
int main()
{
cin>>n;
cin>>st;
for(int i=0;i<=st.size()-1;i++)
{
s=(int(st[i])+n-97)%26;
if(s==0) cout<<"a"; else cout<<char(s+97);
}
return 0;
}
差不多的方法。
by MTer @ 2017-01-10 10:24:52
z+25会溢出