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