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:

15 43 71

Sample Output:

#123456

题目解析
  本题给出3个10进制数字要求转换为13进制数字并输出,根据题意我们可以得出,转化后的每一个数字都不会超过两位。

  这样我们可以将十进制数字0~12与对应13进制数字利用map建立映射。之后将每个数字对应输出即可。

 #include <bits/stdc++.h>
using namespace std;
map<int, char> radix;
void init(){ //建立十进制数与对应13进制数的映射
for(int i = ; i < ; i++)
radix[i] = i + '';
radix[] = 'A';
radix[] = 'B';
radix[] = 'C';
}
int main()
{
init();
int red, green, blue;
scanf("%d%d%d", &red, &green, &blue);
//输入三个十进制数
//输出时先输出#
cout << "#" << radix[red / ] << radix[red % ];
//输出转化后的两位数
cout << radix[green / ] << radix[green % ];
cout << radix[blue / ] << radix[blue % ] << endl;
return ;
}

PTA (Advanced Level) 1027 Colors in Mars的更多相关文章

  1. PAT (Advanced Level) 1027. Colors in Mars (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

  2. PTA(Advanced Level)1044.Shopping in Mars

    Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diam ...

  3. PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...

  4. PAT 甲级 1027 Colors in Mars (20 分)

    1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...

  5. PAT 1027 Colors in Mars

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

  6. PAT 1027 Colors in Mars[简单][注意]

    1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar w ...

  7. 1027 Colors in Mars (20 分)

    1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...

  8. pat 1027 Colors in Mars(20 分)

    1027 Colors in Mars(20 分) People in Mars represent the colors in their computers in a similar way as ...

  9. PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

随机推荐

  1. IFNULL函数

    MySQL函数里有一个很有用的函数IFNULL,它的形式是IFNULL(fieldA,fieldB),意义是当字段fieldA是NULL时取fieldB,不是NULL时取fieldA的值. 这个函数与 ...

  2. java多线程 —— 两种实际应用场景模拟

    最近做的偏向并发了,因为以后消息会众多,所以,jms等多个线程操作数据的时候,对共享变量,这些要很注意,以防止发生线程不安全的情况. (一) 先说说第一个,模拟对信息的发送和接收.场景是这样的: 就像 ...

  3. Team Foundation Server 开发流程管理管理研讨会

    这周,和微软公司的朋友一起,受北京某金融企业邀请,为企业软件部门一个70多人的软件团队提供了一场基于Team Foundation Server的软件软件流程的技术研讨会.在研讨会中,培训基于微软Te ...

  4. Android实现带下划线的EditText(BUG修正)

    之前写了一个关于实现EditText显示下划线的例子,发现仍然存在一些问题,在此继续探索,原文链接:http://www.cnblogs.com/ayqy/p/3599414.html (零)另一个b ...

  5. (转)(WinForm)FormBorderStyle属性

    原地址

  6. Java编程中获取键盘输入实现方法及注意事项

    Java编程中获取键盘输入实现方法及注意事项 1. 键盘输入一个数组 package com.wen201807.sort; import java.util.Scanner; public clas ...

  7. Tomcat 服务器开启失败故障

    Server Tomcat v8.0 Server at localhost failed to start.故障 原因:1.可能是web.xml中的filter-mapping中url-patter ...

  8. 【bug记录】jpa 解决org.hibernate.lazyinitializationexception could not initialize proxy - no session

    前言 最近开发项目比较忙,Spring Cloud的笔记得稍稍放放了,下午出来个bug,恶心的不行,功能很简单,也没有什么级联或复杂的映射关系,就是一直在报三个异常 Caused by: com.fa ...

  9. Two Pointers-349. Intersection of Two Arrays

    Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1] ...

  10. 七,apache配置域名

    配置域名服务器流程: (1)在httpd.conf中启用虚拟主机,Include conf/extra/httpd-vhosts.conf前面的#去掉. (2)在httpd.conf中修改项目路径为自 ...