PTA甲级——1027
1027 Colors in Mars
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 Red
, the middle 2 digits for Green
, and the last 2 digits for Blue
. The only difference is that they use radix 13 (0-9 and A-C) instead of 16. Now given a color in three decimal numbers (each between 0 and 168), you are supposed to output their Mars RGB values.
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 #
, then followed by a 6-digit number where all the English characters must be upper-cased. If a single color is only 1-digit long, you must print a 0
to its left.
Sample Input:
1 |
|
Sample Output:
1 |
|
思路
纯纯模拟十三进制和10进制之间转换问题,这里需要注意下,我们在使用to_string函数的时候,参数我们只可以选择int、longlong、double等类型的,但是对于char类型的数据它是不可以用to_string转的,函数会将char类型数据先转换为int类型再进行计算导致结构输出错误,这个时候就建议大家可以选择使用char数组的方式来编写代码了
代码
1 |
|