#include <stdio h=""> #include <string h=""> #include <ctype h=""> #include<iostream> #include<sstream> using namespace std; int main(void) { int digital, len, times; string ch; while (getline(cin,ch)) { int times=1; int digital = 0; for (len = ch.size() - 1; len >= 2; --len) { ch[len] = tolower(ch[len]); if (ch[len] >= 'a' && ch[len] <= 'f') { digital += (ch[len] - 87) * times; } else if (ch[len] >= 'A' && ch[len] <= 'F') { digital += (ch[len] - 55) * times; } else if (isdigit(ch[len])) digital += (ch[len] - 48) * times; else { break; } times *= 16; } printf("%d\n",digital); } return 0; } </sstream></iostream></ctype></string></stdio>