|
People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Input Specification:Each input file contains one test case which occupies a line containing the three decimal color values. Output Specification:For each test case you should output the Mars RGB value in the following format: first output |
Sample Input:
15 43 71
Sample Output:
#123456
题目大意
给三个十进制的数,转成十三进制输出
思路
见代码
C/C++
#include<bits/stdc++.h>
using namespace std;
string OP(int num){
string key = "00";
key[0] = num/13>9 ? 'A'+num/13-10:'0'+num/13;
key[1] = num%13>9 ? 'A'+num%13-10:'0'+num%13;
return key;
}
int main()
{
int num;
cout << "#";
for(int z=0;z<3;z++){
cin >> num;
cout << OP(num);
}
return 0;
}
442

被折叠的 条评论
为什么被折叠?



