简介

简单

code

#include <iostream>
#include <string>
#include <map>
#include <cmath>
using namespace std;


int main() {
    string s;
    map<char, int> m;
    for(int i=0; i<10; i++){
        m['0' + i] = i;
    }
    m['A'] = 10;
    m['B'] = 11;
    m['C'] = 12;
    m['D'] = 13;
    m['E'] = 14;
    m['F'] = 15;
    while(cin >> s) {
        int re = 0;
        for(int i=s.size() - 1; i>1; i--){
            re = re + m[s[i]] * pow(16, (s.size() - i - 1));
        }
        cout << re << endl;
    }
}
posted on 2021-06-22 16:30  HDU李少帅  阅读(53)  评论(0编辑  收藏  举报