题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <ctype.h> #include <stdio.h> #include <string.h> int main() { char str[101]; char table[] = "cfilosvz"; scanf("%s", str); for (int i = 0; i < strlen(str); i++) { if (islower(str[i])) { for (int j = 0; j < 8; j++) if (str[i] <= table[j]) { printf("%c", '2' + j); break; } } else if (isupper(str[i])) { str[i] += str[i] == 'Z' ? -25 : 1; printf("%c", tolower(str[i])); } else printf("%c", str[i]); } }