#include<bits/stdc++.h>
using namespace std;
int main() {
string str = "";
while(cin >> str) {
int ans = 0, temp = 1;
for(int ii = str.size() - 1; ii > 1; ii--) {
if(str[ii] >= '0' && str[ii] <= '9') ans += temp * (str[ii] - '0');
else ans += temp * (str[ii] - 'A' + 10);
temp *= 16;
}
cout << ans << endl;
}
return 0;
}
【华为机试题 C++】HJ5 进制转换
最新推荐文章于 2024-07-10 17:25:38 发布