题解 | #简单密码#

简单密码

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

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        //A:65 a:97
        for(char ch : str.toCharArray()){
            int n = (int) ch;
            if(n>= 97 && n<=122){
                if(n<=111){
                    System.out.print((n-97)/3 + 2);
                }
                else if(n<=115){
                    System.out.print(7);
                }
                else if(n<=118){
                    System.out.print(8);
                }else{
                    System.out.print(9);
                }
                continue;
            }
            if(n>=65 && n<=90){
                if(n == 90){
                    System.out.print((char)97);
                }else{
                    System.out.print((char)(n+32+1));
                }
                continue;
            }
            System.out.print(ch);
        }
    }
}

全部评论

相关推荐

运营3年修炼中接简历辅导:你的科研项目经历里,只写了你的动作,没有写你的思考和成果,不要只写使用什么进行了什么,这等于罗列你的任务,简历是为了突出你的优秀,你在什么样的任务背景下,克服了什么样的困难,针对性地做了哪些事情,最后达成了什么成果(用数据体现你的成果和效率)
点赞 评论 收藏
分享
03-25 16:22
南华大学 Java
不敢追175女神:你是打了上千个招呼吧?😂
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务