PAT 1027. Colors in Mars_#define



题意: 给出 红 绿 蓝 三个颜色的值,把这3个值分别转成13进制并一起输出


注意点:很简单的转换。注意 168 0 1的转换为 CC0001即可。


//628K  94MS
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<stack>
#include<vector>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
#define M 2500




int main(){

int num[3],c;
char low,high;

scanf("%d%d%d",&num[0],&num[1],&num[2]);

cout<<"#";
for(int i=0;i<3;i++)
{
c = num[i];
low = c % 13;
c = c / 13;
high = c % 13;
if( low >= 10)
low = 'A' + low - 10;
else low = '0' + low;

if( high >= 10)
high = 'A' + high - 10;
else high = '0' + high;

cout<<high<<low;
}
cout<<endl;


}