Juliet @ 2016-02-16 17:30:12
#include <iostream>
using namespace std;
int n;
int main()
{
scanf("%d",n);
char s[100],s1[100];
gets(s);
int k = strlen(s);
for(int i = 0;i<k;i++)
{
if( ( s[i] + n ) > 'z' )
s1[i] = (s[i]- 26 + n);
else
s1[i] = (s[i]+n);
}
for(int i = 0;i<k;i++)
cout<<s1[i];
return 0;
}
by Juliet @ 2016-02-16 17:33:06
改了后的,之前那个cin用多了。。还是错。
#include <iostream>
using namespace std;
int n;
int main()
{
scanf("%d",&n);
char s[100],s1[100];
gets(s);
int k = strlen(s);
for(int i = 0;i<k;i++)
{
if( ( s[i] + n ) > 'z' )
s1[i] = (s[i]- 26 + n);
else
s1[i] = (s[i]+n);
}
for(int i = 0;i<k;i++)
cout<<s1[i];
return 0;
}