题解 | #简单密码#
简单密码
http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac
纯纯写屎山 用了for each 记住ascII,没别的 48,68,97
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String str = scan.nextLine();
StringBuilder strb = new StringBuilder();
for(char c : str.toCharArray()){
if( c>=97 && c<= 99){
strb.append('2');
}
else if( c>=100 && c<= 102){
strb.append('3');
}
else if( c>=103 && c<= 105){
strb.append('4');
}
else if( c>=106 && c<= 108){
strb.append('5');
}
else if( c>=109 && c<= 111){
strb.append('6');
}
else if( c>=112 && c<= 115){
strb.append('7');
}
else if( c>=116 && c<= 118){
strb.append('8');
}
else if( c>=119 && c<= 122){
strb.append('9');
}
else if( c>='A' && c<='Y'){
c += 33;
strb.append(c);
}
else if( c == 'Z'){
c = 'a';
strb.append(c);
}
else if( c>= '0' && c<= '9'){
strb.append(c);
}
}
System.out.println(strb.toString());
}
}