bluetored @ 2022-09-18 22:29:06
#include <stdio.h>
#include <string.h>
int main ()
{
char a[51];
int n;
scanf ("%d",&n);
scanf ("%s",a);
int len = strlen(a);
for (int i=0;i<len;i++)
{
a[i]=a[i]+n;
if (a[i]>'z')
{a[i]=a[i]-26;}
}
printf ("%s",a);
}
by jmh_AK_IOI @ 2022-09-19 07:35:28
需要用string,不是char, s[i]=(s[i]-'A'+n+26)%26+'A'; s[i]=(s[i]-'a'+n+26)%26+'a';