- public static void main(String[] args)
- {
- char[] ans ={'b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a'};
- char[] res ={'2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','7','7','7','8','8','8','9','9','9','9'};
-
- Scanner cin = new Scanner(System.in);
- String str = null;
- String Out = null;
- while(cin.hasNext())
- {
- Out = "";
- str = cin.next();
- for(int i=0;i<str.length();i++)
- {
- char tmp = str.charAt(i);
- if(tmp>='a'&&tmp<='z')
- {
- Out+=res[tmp-'a'];
- }
- else if(tmp>='A'&&tmp<='Z')
- {
- Out+=ans[tmp-'A'];
- }
- else
- {
- Out+=tmp;
- }
- }
- System.out.println(Out);
- }
- }
复制代码 希望你能看得懂......
不是按照你的思路来写的.... |