A1027. 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
Each input file contains one test case which occupies a line containing the three decimal color values.
Output
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 the left.
Sample Input
15 43 71
Sample Output
#123456
#include<cstdio>
#include<iostream>
using namespace std;
void radix(int n){
int a, b;
a = n / ;
b = n % ;
if(a >= )
printf("%c", 'A' + a - );
else
printf("%c", '' + a);
if(b >= )
printf("%c", 'A' + b - );
else
printf("%c", '' + b);
} int main(){
int r, g, b;
scanf("%d%d%d", &r, &g, &b);
printf("#");
radix(r);
radix(g);
radix(b);
cin >> r;
return ; }
仍然是进制转换问题。为了方便输出0-9、A、B、C,可以将这13个字符存在字符数组中,建立0-12的对应关系。
A1027. Colors in Mars的更多相关文章
- A1027 Colors in Mars (20)(20 分)
A1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar ...
- PAT甲级——A1027 Colors in Mars
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT A1027 Colors in Mars (20)
AC代码 #include <cstdio> const int max_n = 1000; int ans[max_n]; char result[max_n]; char radix[ ...
- 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- PAT1027:Colors In Mars
1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...
- 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 ...
- PAT 1027 Colors in Mars
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- PAT 1027 Colors in Mars[简单][注意]
1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar w ...
- PTA (Advanced Level) 1027 Colors in Mars
Colors in Mars People in Mars represent the colors in their computers in a similar way as the Earth ...
随机推荐
- 时区提示:Local time zone must be set--see zic manual page 2018的解决办法
问题描述:在centos服务器上执行date命令时,显示的时间信息中的时区不正常,如下: [root@ulocalhost ~]# date Mon Apr 9 02:57:38 Local time ...
- Centos下安装破解confluence6.3的操作记录
confluence是一个专业的企业知识管理与协同软件,可以用于构建企业wiki.通过它可以实现团队成员之间的协作和知识共享.现在大多数公司都会部署一套confluence,用作内部wiki.现在co ...
- html转js字符串拼接
https://www.bejson.com/convert/html_js/ html转js字符串拼接
- 12.15 Daily Scrum
Today's Task Tomorrow's Task 丁辛 实现和菜谱相关的餐厅列表. 实现和菜谱相关的餐厅列表. 邓亚梅 美化搜索框UI. 美 ...
- alpa开发阶段团队贡献分
这是我们团队之前决定的分配方式: 1.凡是认真完成自己任务的队员,都将有基础分30分(态度分). 2. 将整个项目细化为不同的任务,列出一个任务清单,在综合.协调完每名成员的意愿后,我会分配清单中的任 ...
- 《Linux内核分析》期终总结
作者:杨舒雯,原创作品转载请注明出处,<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 目录: 1.通过简 ...
- octave基本指令2
octave基本指令2 数据移动 >> pwd %显示出当前路径 ans C:\Octave\3.2.4_gcc-4 >> cd 'G:\machine learning' % ...
- 开源的CAS实现SSO
https://www.ibm.com/developerworks/cn/opensource/os-cn-cas/index.html ISC是基于CAS定制的,使用的高级的代理模式. https ...
- mysql 和php 保留2位小数
一般交易中保留的数字的小数位数为2位(即最小单位为 1分钱[0.01元]) 数据库设计中预金钱有关或要求精准度要高的用 decimal(n,m) 表示,n表示保留的数字长度,保留的小数位数,如deci ...
- php 7.1 openssl_decrypt() 代替 mcrypt_module_open() 方法
公司开发微信第三方平台,之前用着一直是没有问题的.后来服务器到期进行项目搬迁就怎么也接收不到微信每10分钟的ticketle. 经过调试发现php版本由原来的7.0升到了7.1(该死....为什么没人 ...