https://ask.csdn.net/questions/7958783/54227935?spm=1001.2014.3001.5504
刚回答过
稍微修改下
#include <stdlib.h>
int main()
{
char s[100];
int isenc;
int offset;
scanf("%d", &isenc);
scanf("%s", s);
scanf("%d", &offset);
if (isenc)
{
for (char *i = s; *i; i++)
if ('a' <= *i && 'z'>=*i)
if (*i + offset > 'z')
printf("%c", *i - 26 + offset);
else
printf("%c", *i + offset);
else
printf("%c", *i);
}
else
{
for (char *i = s; *i; i++)
if ('a' <= *i && 'z'>=*i)
if (*i - offset < 'a')
printf("%c", *i + 26 - offset);
else
printf("%c", *i - offset);
else
printf("%c", *i);
}
return(0);
}
不知道你这个问题是否已经解决, 如果还没有解决的话: