这道题要是考试能遇到,全村敲锣打鼓摆三天流水席。就是一个进制转换完事了,一点多于操作都没有。
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
char p[] = "0123456789ABC";
string ps(int n)
{
string s;
int t = n;
while(t!=0)
{
s += p[t%13];
t /= 13;
}
while(s.length()<2)
s += "0";
reverse(s.begin(), s.end());
cout << s;
}
int main()
{
int r, g, b;
char p[] = "0123456789ABC";
scanf("%d %d %d", &r, &g, &b);
cout << "#";
ps(r);
ps(g);
ps(b);
return 0;
}