#进制转换#__huawei_no.4-1
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
string str;
getline(cin, str);
string str2 = str.substr(2);
reverse(str2.begin(), str2.end());
int n = str2.size();
int ans = 0;
int num = 0;
for (int i = 0 ; i < n; i++) {
if (str2[i] >= 'A' && str2[i] <= 'F' ) {
num = 10 + (str2[i] - 'A');
} else if (str2[i] >= 'a' && str2[i] <= 'f' ) {
num = 10 + (str2[i] - 'a');
} else {
num = str2[i] - '0';
}
ans += num * pow(16, i);
}
cout << ans << endl;
}
// 64 位输出请用 printf("%lld")
简单粗暴的方法,不能跟大佬比
