题解 | #简单密码#
简单密码
https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <stdio.h> #include <string.h> #include <ctype.h> int main() { char input[100]; scanf("%s", input); int len = strlen(input); for (int i = 0; i < len; i++) { char t = input[i]; if(islower(t)){ if(t >= 'a' && t <= 'c') input[i] = '2'; else if(t >= 'd' && t <= 'f') input[i] = '3'; else if(t >= 'g' && t <= 'i') input[i] = '4'; else if(t >= 'j' && t <= 'l') input[i] = '5'; else if(t >= 'm' && t <= 'o') input[i] = '6'; else if(t >= 'p' && t <= 's') input[i] = '7'; else if(t >= 't' && t <= 'v') input[i] = '8'; else input[i] = '9'; } else if(isupper(t)){ if(t == 'Z') input[i] = 'a'; else input[i] += 33; } } printf("%s\n", input); }