题解 | #进制转换#

进制转换

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

#include <iostream>
using namespace std;

int main() {
    string str;
    while(cin>>str){
        int res=0;
        for(int i=2;i<str.size();i++){
            if(str[i]>='0'&&str[i]<='9')res=16*res+str[i]-'0';
            else res=16*res+str[i]-'A'+10;
        }
        cout<<res<<endl;
    }
}

全部评论

相关推荐

05-24 14:12
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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