Z1660402068 @ 2024-01-27 19:54:27
#include <stdio.h>
#include <string.h>
char s[51];
int main ()
{
int n;
scanf("%d",&n);
scanf("%s",s);
int h=strlen(s);
for(int i=0;i<h;i++)
{
s[i]=n+s[i];
while(s[i]>122)
s[i]=(s[i]-26);
}
for(int i=0;i<h;i++)
{
printf("%c",s[i]);
}
return 0;
}
by Rieman_sum @ 2024-01-27 20:06:00
@Z1660402068 z要变成a
by Z1660402068 @ 2024-01-27 20:23:51
@Guo1 啥意思
by Z1660402068 @ 2024-01-28 15:39:56
@Guo1 懂了
by Hja2004 @ 2024-01-29 15:03:45
s[i]=(s[i]-97+n)%26+'a';//容易越界 (ascii) ascii最大为127,在'z'+n(n<=26)可能会大于127,从而越界,但是结果不会越界,所以要减少步骤,直到每个步骤都不会越界
by Z1660402068 @ 2024-01-29 15:26:18
@Hja200ok
by TripFriend1130 @ 2024-02-02 11:38:08
3,4测试点以下两处要特判:\
1,如果