题解 | #简单密码#

简单密码

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

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String s = scanner.nextLine();
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) >= 97 && s.charAt(i) <= 114) {
                    System.out.print((s.charAt(i) - 97) / 3 + 2);
                } else if (s.charAt(i) == 115) {
                    System.out.print(7);
                } else if (s.charAt(i) >= 116 && s.charAt(i) <= 118) {
                    System.out.print(8);
                } else if (s.charAt(i) >= 119 && s.charAt(i) <= 122) {
                    System.out.print(9);
                } else if (s.charAt(i) >= 65 && s.charAt(i) <= 89) {
                    System.out.print((char) (s.charAt(i) + 33));
                } else if (s.charAt(i) == 90) {
                    System.out.print('a');
                } else {
                    System.out.print(s.charAt(i));
                }
            }
        }
    }
}
全部评论

相关推荐

07-24 19:01
门头沟学院 Java
后天笔试,又要开始做题了
Sairus:明天10:00笔试
投递京东等公司10个岗位
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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