题解 | #进制转换#

进制转换

http://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6

import java.util.Scanner;
public class Main {
 public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        if(str.substring(0,2).equals("0x")){
            int x=Integer.parseInt(str.substring(2),16);
            System.out.println(x);
        }else {
            int x=Integer.parseInt(str,16);
            System.out.println(x);
        }


    }       
}
全部评论

相关推荐

2025-12-27 22:14
门头沟学院 Java
点赞 评论 收藏
分享
2025-11-07 11:05
已编辑
腾讯_csig_软件开发(实习员工)
点赞 评论 收藏
分享
2025-12-01 15:04
吉首大学 后端工程师
冲鸭2024:亚信不去也罢
投递亚信科技(中国)有限公司等公司8个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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