#include<iostream>
using namespace std;
int main()
{
int r,g,b;
char radix[13]={'0','1','2','3','4','5','6','7','8','9','A','B','C'};
cin>>r>>g>>b;
cout<<"#";
cout<<radix[r/13]<<radix[r%13];
cout<<radix[g/13]<<radix[g%13];
cout<<radix[b/13]<<radix[b%13];
system("pause");
return 0;
using namespace std;
int main()
{
int r,g,b;
char radix[13]={'0','1','2','3','4','5','6','7','8','9','A','B','C'};
cin>>r>>g>>b;
cout<<"#";
cout<<radix[r/13]<<radix[r%13];
cout<<radix[g/13]<<radix[g%13];
cout<<radix[b/13]<<radix[b%13];
system("pause");
return 0;
}
用传统进制转换会较为复杂,用上述方法较为简单。