题解 | 进制转换

进制转换

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

parseInt方法,它在Java中用于将字符串解析为整数,后面的16表示要转化的字符串以16进制看待。

#牛客春招刷题训练营# https://www.nowcoder.com/discuss/730470342107340800

import java.io.*;
import java.util.*;

public class Main{
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextLine()){
            String s = sc.nextLine();
            System.out.println(Integer.parseInt(s.substring(2,s.length()),16));
        }
    }
}

#牛客春招刷题训练营#
全部评论

相关推荐

05-22 17:07
已编辑
广东石油化工学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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