#include<iostream>
#include<cstdlib>
using namespace std;
void exchange_DH(int n)
{
int i=0,m,num[100];
char hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
while(n>0)
{
num[i++]=n%16;
n=n/16;
}
for(i=i-1;i>=0;i--)
{
m=num[i];
cout<<hex[m];
}
cout<<endl;
}
int main()
{
while(1)
{
int n;
cin>>n;
exchange_DH(n);
}
return 0;
}
原博地址
https://blog.csdn.net/weixin_43673589