#include <stdio.h>
char *Change(char s[]) {
int i;
for(i = 0; s[i]; ++i) {
if(s[i] >= 'a' && s[i] <= 'z')
s[i] = (26 + (s[i] - 'a' - 3))%26 + 'a';
if(s[i] >= 'A' && s[i] <= 'Z')
s[i] = (26 + (s[i] - 'A' + 3))%26 + 'A';
}
return s;
}
char *Change2(char s[]) {
int i;
for(i = 0; s[i]; ++i) {
if(s[i] >= 'a' && s[i] <= 'z')
s[i] = (26 + (s[i] - 'a' + 3))%26 + 'a';
if(s[i] >= 'A' && s[i] <= 'Z')
s[i] = (26 + (s[i] - 'A' - 3))%26 + 'A';
}
return s;
}
int main() {
char a[] = "dsereaiklfiwieik",b[] = "slASSFGGHHJHKKIUUYUYYHHNJKK";
printf("转换前: %s\n",a);
printf("转换后: %s\n",Change(a));
printf("恢复后: %s\n\n",Change2(a));
printf("转换前: %s\n",b);
printf("转换后: %s\n",Change(b));
printf("恢复后: %s\n",Change2(b));
return 0;
}
温馨提示:答案为网友推荐,仅供参考