思路:
遍历每个字符:
1.将大写英文字符+32变为小写,+1后移一位。
2.将小写英文字符a-r统一转为数字,s-z单独处理转为数字
3.输出
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
while(in.hasNext()){
String str=in.nextLine();
char c[]=str.toCharArray();
for(int i=0;i<str.length();i++){
if(c[i]>='A'&&c[i]<='Z'){
if(c[i]+32!='z')
c[i]+=32+1;
else
c[i]='a';
}
else if(c[i]>='a'&&c[i]<='r')
c[i]=(char) ((c[i]-'a')/3+2+'0');
else if(c[i]=='s')
c[i]='7';
else if(c[i]>='t'&&c[i]<='v')
c[i]='8';
else if(c[i]>='w'&&c[i]<='z')
c[i]='9';
System.out.print(c[i]);
}
System.out.println();
}
}
}

京公网安备 11010502036488号