题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
#include <stdio.h> #include <string.h> int main(void) { char input[1000]; char output[1000] = "\0"; int Nnum = 0,Enum = 0,Knum = 0,Onum = 0; gets(input); { for(int i=0;i<strlen(input);i++) { if(input[i] >= 'A' && input[i] <= 'Z')//大写 { if(input[i] == 'Z') output[i] = 'a'; else output[i] = input[i] + 32 + 1;//转换为小写 } else if(input[i] >= 'a' && input[i] <= 'z')//小写 { if(input[i]>='a' && input[i]<='c') output[i]='2'; else if(input[i]>='d' && input[i]<='f') output[i]='3'; else if(input[i]>='g' && input[i]<='i') output[i]='4'; else if(input[i]>='j' && input[i]<='l') output[i]='5'; else if(input[i]>='m' && input[i]<='o') output[i]='6'; else if(input[i]>='p' && input[i]<='s') output[i]='7'; else if(input[i]>='t' && input[i]<='v') output[i]='8'; else if(input[i]>='w' && input[i]<='z') output[i]='9'; } else//数字 output[i] = input[i]; } printf("%s\n",output); return 0; } }