题解 | #进制转换#
进制转换
http://www.nowcoder.com/practice/deb19498bc644f53a6a99905ef5ee01d
#include <iostream>
using namespace std;
int main()
{
string hex;
while (cin >> hex)
{
hex = hex.substr(2);
long long res = 0;
for (int i = 0; i < hex.size(); ++i)
{
int n;
if (hex[i] >= 'A' && hex[i] <= 'F')
n = hex[i] - 'A' + 10;
else
n = hex[i] - '0';
res = res * 16 + n;
}
cout << res << endl;
}
return 0;
}