秘晨阳 @ 2017-08-07 20:40:32
#include<bits/stdc++.h>
using namespace std;
int n,l;
char a[101];
int main()
{
cin>>n>>a;
l=strlen(a);
for(int i=0;i<l;i++)
{a[i]=a[i]+n;
while(a[i]>'z')
a[i]=a[i]-'z'+'a'-1;
}
for(int i=0;i<l;i++)
cout<<a[i];
}
by huangzirui @ 2017-08-09 17:52:10
正解:
#include<bits/stdc++.h>
using namespace std;
int n,l;
char a[101];
int main()
{
cin>>n>>a;
l=strlen(a);
for(int i=0;i<l;i++)
for(int j=1;j<=n;j++)
{a[i]=a[i]+1;
while(a[i]>'z')
a[i]=a[i]-'z'+'a'-1;
}
for(int i=0;i<l;i++)
cout<<a[i];
}
by 夏夜空 @ 2017-08-10 20:06:20
#include<iostream>
#include<string>
using namespace std;
int n;
string s;
int main(){
cin>>n;
cin>>s;
for(int i=0;i<s.size();i++){
int x=int(s[i]-'a');
x+=n;
x=x%26;
cout<<char(x+'a');
}
}