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 ...
随机推荐
- 如何手动写一个Python脚本自动爬取Bilibili小视频
如何手动写一个Python脚本自动爬取Bilibili小视频 国庆结束之余,某个不务正业的码农不好好干活,在B站瞎逛着,毕竟国庆嘛,还让不让人休息了诶-- 我身边的很多小伙伴们在朋友圈里面晒着出去游玩 ...
- 插件GsonFormat快速生成JSon实体类
IntelliJ IDEA 个人觉得是目前最好最强最智能的Java IDE,默认已经集成了几乎所有主流的开发工具和框架. 1.常用工具支持Java日常开发需要接触到很多常用的工具,为了便于使用,很多工 ...
- Vue Element Tabe Pager 分页方案
表格和分页分离的,但是使用中,却是结合在一起的. 分析 有以下方式触发查询: mounted 加载数据. 查询按钮 加载数据. pager 变化加载数据 加载数据函数: loadData 问题 mou ...
- Visual Studio2013的安装过程及练习测试
一.安装环境: 支持安装的操作系统版本:Windows XP,Windows7,Windows8,Windows10. CPU大小:Intel(R)Core(TM)i5-4210U CPU @1.7G ...
- html转js字符串拼接
https://www.bejson.com/convert/html_js/ html转js字符串拼接
- ros-安装
1.安装了ubuntu for ros. 运行评论下边那条命令: 2.rtabamp 3.准备安装机器人导航仿真系统:https://blog.csdn.net/wangchao7281/articl ...
- UserControl 的一个值得注意的问题 [属性" * "的代码生成失败.错误是:"程序集"*.Version=1.0.0.0,Culture=neutral,..........无标记为序列化"
开发时在做UserControl,需要注意的List<>集合问题~~~! 其他类型的集合可能也存在这样的问题,但是我没去测试,在写集合的时候一般List<>用的多点,所以经常碰 ...
- 初识nginx——内存池篇
初识nginx——内存池篇 为了自身使用的方便,Nginx封装了很多有用的数据结构,比如ngx_str_t ,ngx_array_t, ngx_pool_t 等等,对于内存池,nginx设计的十分精炼 ...
- 面象对象设计原则之三:里氏替换原则(The Liskov Substitution Principle,LSP)
里氏代换原则由2008年图灵奖得主.美国第一位计算机科学女博士Barbara Liskov教授和卡内基·梅隆大学Jeannette Wing教授于1994年提出.其严格表述如下:如果对每一个类型为S的 ...
- Oracle 和 SQLSERVER 重新获取统计信息的方法
1. Oracle 重新获取统计信息的命令 exec dbms_stats.gather_schema_stats(ownname =>) # 需要修改 ownername options 指定 ...