题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/8f3df50d2b9043208c5eed283d1d4da6
#include <cctype> #include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; string::iterator it = s.end(); long long ans=0; long long cnt = 1; while (*(--it)!='x') { char c = *(it); if(isdigit(c)){ ans = ans+ (c-'0')*cnt; }else{ ans += (10+c-'A')*cnt; } cnt *= 16; } cout << ans << endl; return 0; } // 64 位输出请用 printf("%lld")#每日一题#