#include
#include
int main(void) {
char str[100], *c;
printf("Input a string: ");
gets(str);
for (c = str; *c; c++) {
if (islower(*c)) {
if (*c >= 'x') *c -= 23;
else *c += 3;
} else if (islower(*c)) {
if (*c <= 'C') *c += 23;
else *c -= 3;
}
}
puts(str);
return 0;
}
/* 不符合题目要求,但仍然管用 */
#include
char lower_case[] = "defghijklmnopqrstuvwxyzabc";
char upper_case[] = "XYZABCDEFGHIJKLMNOPQRSTUVW";
int main(void) {
int c;
printf("Input a string: ");
while ((c = getchar()) != '\n') {
if ((c >= 'a') && (c < 'z'))
c = lower_case[c - 'a'];
else if ((c >= 'A') && (c <= 'Z'))
c = upper_case[c - 'A'];
putchar(c);
}
return 0;
}