#include<iostream> #include<string> using namespace std; int main() { string s; while(getline(cin,s)) { cout<<stoi(s,0,16)<<endl;//stoi(字符串,起始位置,n进制),将 n 进制的字符串转化为十六进制 //将字符串 s 从 0 位置开始到末尾的 2 进制转换为十六进制. } return 0; }
#include<iostream> #include<string> using namespace std; int main() { string s; while(getline(cin,s)) { cout<<stoi(s,0,16)<<endl;//stoi(字符串,起始位置,n进制),将 n 进制的字符串转化为十六进制 //将字符串 s 从 0 位置开始到末尾的 2 进制转换为十六进制. } return 0; }