PAT (Advanced Level) 1027. Colors in Mars (20)
简单题。
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; void pri(int a) { if (a <= 9) printf("%d", a); else printf("%c", a-10+'A'); } void print(int a){ if (a >= 13) { pri(a/13); pri(a%13);} else { printf("0"); pri(a); } } int main() { int r, g, b; scanf("%d%d%d", &r, &g, &b); printf("#"); print(r); print(g); print(b); printf("\n"); return 0; }