1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 14:36:19 +00:00
202401-programming-assignments/【实践课内】9.数组3/7-2 字符串替换.c

24 lines
375 B
C
Raw Normal View History

2024-11-15 08:03:08 +00:00
#include <stdio.h>
const char REPLACE_MAP[] = "ZYXWVUTSRQPONMLKJIHGFEDCBA";
char s[100];
int main() {
gets(s);
int len = strlen(s);
for (int i = 0; i < len; i++) {
if (s[i] >= 'A' && s[i] <= 'Z') {
printf("%c", REPLACE_MAP[s[i] - 'A']);
} else {
printf("%c", s[i]);
}
}
printf("\n");
return 0;
}