题解 | #进制转换#

进制转换

https://www.nowcoder.com/practice/deb19498bc644f53a6a99905ef5ee01d

#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int char2int(char x){
    if(x>='0'&&x<='9') return x-'0';
    else  return x-'A'+10;
}

int main() {
    string hex;
    while(cin>>hex){
        long long num=0;
        for(int i=2;i<hex.length();i++){
            num=num*16+char2int(hex[i]);
        }
        cout<<num<<endl;
    }
}

全部评论

相关推荐

迷茫的大四🐶:价格这么低都能满了?
点赞 评论 收藏
分享
浩浩没烦恼:一二面加起来才一个小时? 我一面就一个小时多了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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