legend3366 @ 2021-11-09 22:42:10
#include <stdio.h>
#include <string.h>
int main()
{
char sb[999] = { 0 };
int n, len;
scanf("%d", &n);
scanf("%s",sb);
len = strlen(sb);
for (int i = 0; i < len; i++)
{
sb[i] += n;
}
for(int i = 0; i < len; i++)
{
if (sb[i] > 122)
{
sb[i] -= 26;
}
printf("%c", sb[i]);
}
return 0;
}
by RocksonLee @ 2021-11-10 08:28:12
超过char的范围(-128~127)了。
应该让sb[i]在加之前就减掉
by Sharona @ 2022-05-06 23:04:05
弱弱地问一句,122是怎么来的