题解 | #简单密码# 懒人方法

简单密码

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

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc =new Scanner(System.in);

        String from="abcdefghijklmnopqrstuvwxyz";

        String to=  "22233344455566677778889999";

        String result=new String();

        if(sc.hasNextLine()){

            String s=sc.nextLine();

            int len=s.length();

            for(int i=0;i<len;i++){

                char temp=s.charAt(i);

                int index=from.indexOf(temp);

                if(index!=-1){

                    result+=to.charAt(index);

                }else{

                    if(temp>='A'&&temp<'Z'){

                        temp+=32+1;

                        result+=temp;

                    }else if(temp=='Z'){

                        result+='a';

                    }else{

                        result+=temp;

                    }

                }

            }

        }

        System.out.println(result);

    }

}

全部评论

相关推荐

用微笑面对困难:你出于礼貌叫了人一声大姐,大姐很欣慰,她真把你当老弟
点赞 评论 收藏
分享
10-29 18:20
济南大学 Java
用微笑面对困难:他不是人事吗,怎么净特么不干人事
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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