直接判断的
#include<stdio.h>
#include<string.h>
int main(){
char str[105],des[105]={0};
char tmp;
while(scanf("%s",str)!=EOF){
for(int i=0;str[i]!=0;i++){
if(str[i]>='A'&&str[i]<='Z'){
tmp='a'+str[i]-'A'+1;
if(tmp>='a'&&tmp<='z'){
des[i]=tmp;
}else{
des[i]='a';
}
}else if(str[i]>='0'&&str[i]<='9'){
des[i]=str[i];
}else{
if(str[i]>='a'&&str[i]<='c'){
des[i]='2';
}else if(str[i]>='d'&&str[i]<='f'){
des[i]='3';
}else if(str[i]>='g'&&str[i]<='i'){
des[i]='4';
}else if(str[i]>='j'&&str[i]<='l'){
des[i]='5';
}else if(str[i]>='m'&&str[i]<='o'){
des[i]='6';
}else if(str[i]>='p'&&str[i]<='s'){
des[i]='7';
}else if(str[i]>='t'&&str[i]<='v'){
des[i]='8';
}else if(str[i]>='w'&&str[i]<='z'){
des[i]='9';
}
}
}
printf("%s\n",des);
}
return 0;
} 
京公网安备 11010502036488号