PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)
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
思路:进制转换
#include <iostream>
#include <string.h>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
char _deal(int x)
{
if(x>=&&x<) return x+'';
else if(x>=) return x+'A'-;
}
int main()
{
int a,b,c;
while(cin>>a>>b>>c){
char s[];
s[]='#';
int tmp=a/;
s[]=_deal(tmp);
tmp=a%;
s[]=_deal(tmp);
tmp=b/;
s[]=_deal(tmp);
tmp=b%;
s[]=_deal(tmp);
tmp=c/;
s[]=_deal(tmp);
tmp=c%;
s[]=_deal(tmp);
printf("%s\n",s);
}
return ;
}
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)的更多相关文章
- 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 ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642
PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) 凌宸1642 题目描述: A number that will ...
- PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642
PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...
- PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642
PAT (Advanced Level) Practice 1005 Spell It Right (20 分) 凌宸1642 题目描述: Given a non-negative integer N ...
- PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642
PAT (Advanced Level) Practice 1001 A+B Format (20 分) 凌宸1642 题目描述: Calculate a+b and output the sum i ...
- PAT (Advanced Level) Practice 1054 The Dominant Color (20 分)
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...
- PAT (Advanced Level) Practice 1019 General Palindromic Number (20 分) (进制转换,回文数)
A number that will be the same when it is written forwards or backwards is known as a Palindromic Nu ...
- PAT (Advanced Level) Practice 1005 Spell It Right (20 分) (switch)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...
- PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) (找最值)
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
随机推荐
- sed命令入门
什么是sed sed是一种流处理编辑器,可以分割.查找.替换文本. sed命令的处理流程:行处理 Created with Raphaël 2.1.0在shell中执行sed文本或管道输入读入到模式空 ...
- DOCKER绝对领域从2048到4069?不:25519,数字的飞跃,HTTP/2
这个标题花了几分钟,远远超过我构思以下内容的时间损耗,希望大家且看且珍惜,因为这是为数不多的cnblog特别标题 我记得很久以前,我开了一系列随笔,从第一篇揭发233的docker/machine开始 ...
- 极简估值教程——第一篇 速判估值与PEG的推导
来自盛京剑客的雪球原创专栏 一.极简速判估值怎么判? 很简单.简单到粗暴. 用PEG PEG=PE/(g*100)=1.0 什么意思? PE市盈率,g未来收益增长率,PEG为1.0合理估值,大于1.0 ...
- vue插件介绍
1.插件和组件的关系 在没有封装组件之前,如果不使用第三方插件,那么很多情况下我们会编写几个常用的组件来提供给页面使用,如Alert/Loading组件,而你可能需要在很多页面中引入并且通过compo ...
- new function 到底做了什么?如何自己实现new function
前言 这是继function 与 Function 关系后写下的. 写这个起源于,我无聊的时候看到一道题目: 'foo' == new function() { var temp=String('fo ...
- Nginx三大主要功能
1.做静态资源服务器,可以用于前端项目发布,图片文件文件等静态服务器. 2.做反向代理服务器,域名往往配置在Nginx上,真正的业务服务器躲在其身后. 3.做负载均衡服务器,作为负载集群的入口网关. ...
- ACP知识总结
由于ACP是一个敏捷开发的系统性知识,下面只针对我自身学习的知识总结,若需要完整的考试学习资料,可评论区或私聊我拿. 敏捷估计与规划.png ACP知识点锦集.png 敏捷项目软件总结.p ...
- SQLyog12.08详细安装教程
SQLyog安装教程 一.软件下载 为了更好的学习,我们需要可视化界面,而不仅仅是通过命令行黑窗口管理数据库.SQLyog 就是一个快速而简洁的图形化管理MYSQL数据库的工具. SQLyog12.0 ...
- Linux运维----03.制作trove-mysql5.7镜像
安装mysql yum install http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm yum remove m ...
- Gird(2)
目录 grid 布局(2) grid区域属性 网格线名称 grid-template-areas 属性 grid-auto-flow 容器内子元素的属性 grid 布局(2) grid区域属性 网格线 ...