题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
#include <iostream> #include <istream> using namespace std; int main() { string s; cin >> s; s = s.substr(2,s.length()-2); int count = 0; int multi = 1; for(int i = 0; i < s.length()-1; ++i) { multi *= 16; } for(int i = s.length() - 1; i >= 0; --i) { s[s.length() - i - 1] - 'A' < 0? count += (s[s.length() - i - 1] - '0') * multi : count += (s[s.length() - i - 1] - 'A' + 10) * multi; multi /= 16; } cout << count <<endl; } // 64 位输出请用 printf("%lld")