You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
425 B

#include<bits/stdc++.h>
using namespace std;
int main() {
string s;
int i=0,count,sum;
while(getline(cin,s)) {
int count=s.length();
sum=0;
for(i=count-1; i>=0; i--) { //从十六进制个位开始,每位都转换成十进制
if(s[i]>='0'&&s[i]<='9') { //数字字符的转换
sum+=(s[i]-48)*pow(16,count-i-1);
} else if(s[i]>='A'&&s[i]<='F') { //字母字符的转换
sum+=(s[i]-55)*pow(16,count-i-1);
}
}
cout<<sum;
}
}