题解 | #简单密码#

简单密码

http://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac

import java.io.*;

public class Main{ public static char[] tab = new char[]{'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','0'}; public static void main(String[] args) throws Exception { InputStream in = System.in; char c; StringBuilder sb = new StringBuilder(); while((c = (char)in.read()) != '\n') { if(c >= 'A' && c < 'Z') { c = (char)(c + 33); } else if(c == 'Z') { c = 'a'; } else if(c >= 'a' && c <= 'z') { c = tab[c - 'a']; } sb.append(c); } System.out.println(sb.toString()); } }

我居南半坡 文章被收录于专栏

多刷题,积蓄力量,欢迎讨论

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务