题解 | #进制转换#

进制转换

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

#include<stdlib.h>
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<string.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long LL;
const int MAXN=1e5+10;
int charToint(char c){
    if(c>='A')return c-'A'+10;
    else return c-'0';
}

int main(){
     string s;
     while(cin>>s){
        s.erase(0,2);
        int number=0;
        for(int i=0;i<s.size();i++){
            number*=16;
            number+=charToint(s[i]);
        }
        cout<<number<<endl;
     }
    return 0;
}

全部评论

相关推荐

05-30 12:03
山西大学 C++
offer来了我跪着接:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
05-12 16:04
已编辑
江西财经大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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