题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
import java.util.;
import java.util.regex.;
public class Main{
public static void main(String[] a){
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
StringBuffer sb = new StringBuffer(s.length());
for(int i=0;i<s.length();i++){
if(s.charAt(i)=='Z'){
sb.append("a");
continue;
}
if(s.charAt(i)>='A'&&s.charAt(i)<'Z'){
int result= s.charAt(i)+1;
sb.append((char)result);
continue;
}
if(s.charAt(i)>='a'&&s.charAt(i)<='c'){
sb.append("2");
continue;
}
if(s.charAt(i)>='d'&&s.charAt(i)<='f'){
sb.append("3");
continue;
}
if(s.charAt(i)>='g'&&s.charAt(i)<='i'){
sb.append("4");
continue;
}
if(s.charAt(i)>='j'&&s.charAt(i)<='l'){
sb.append("5");
continue;
}
if(s.charAt(i)>='m'&&s.charAt(i)<='o'){
sb.append("6");
continue;
}
if(s.charAt(i)>='p'&&s.charAt(i)<='s'){
sb.append("7");
continue;
}
if(s.charAt(i)>='t'&&s.charAt(i)<='v'){
sb.append("8");
continue;
}
if(s.charAt(i)>='w'&&s.charAt(i)<='z'){
sb.append("9");
continue;
}else{
sb.append(s.charAt(i));
}
} System.out.print(sb.toString().toLowerCase()); }
}