题解 | #简单密码#

简单密码

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-16 18:05
何尝不是一种学历歧视呢
下午吃泡馍:这种公司不投也罢,不过建议挂出公司名字,1.1w就应激到问是不是清北也是看得出来不是啥好公司了,估计这hr也没见过啥世面
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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