题解 | #进制转换#
进制转换
https://www.nowcoder.com/practice/deb19498bc644f53a6a99905ef5ee01d
#include <iostream>
#include <string>
#include <cmath>
#include <cctype>
using namespace std;
int transfer(char c){
if(isdigit(c)){
return c-'0';
}
else return c-'A'+10;
}
int main() {
string s;
while (cin >> s) { // 注意 while 处理多个 case
int res=0,iter=0;
for(int i=s.size()-1;s[i]!='x';--i){
res+=transfer(s[i])*pow(16,iter++);
}
cout<<res<<endl;
}
}
// 64 位输出请用 printf("%lld")
查看19道真题和解析