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 ...
随机推荐
- Ambari HDP 下 SPARK2 与 Phoenix 整合
1.环境说明 操作系统 CentOS Linux release 7.4.1708 (Core) Ambari 2.6.x HDP 2.6.3.0 Spark 2.x Phoenix 4.10.0-H ...
- php 安装 event 和 libevent 扩展
这里使用的是php7.0.24 ,php是yum安装的 一.安装event扩展 用yum无法安装event扩展 手动安装 php 必须要开启 sockets 功能,需要安装php的socket扩展,才 ...
- HSRP 详解
简介 HSRP(Hot Standby Router Protocol 热备份路由器协议)是Cisco的专有协议.HSRP把多台路由器组成一个“热备份组”,形成一个虚拟路由器.这个组内只有一个路由器是 ...
- vi/vim编辑器操作梳理
1. vi/vim编辑器详细使用讲解 1.1 vi/vim编辑器的3种模式 1.2 vi/vim编辑器操作说明 参数/命令/模式 说明 ###普通模式 :set nu 显示行号 :set non ...
- HDU Ignatius and the Princess II 全排列下第K大数
#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include& ...
- Python性能优化方案
Python性能优化方案 从编码方面入手,代码算法优化,如多重条件判断有限判断先决条件(可看 <改进python的91个建议>) 使用Cython (核心算法, 对性能要求较大的建议使用C ...
- [dubbo 源码之 ]1. 服务提供方如何发布服务
服务发布 启动流程 1.ServiceConfig#export 服务提供方在启动部署时,dubbo会调用ServiceConfig#export来激活服务发布流程,如下所示: Java API: ` ...
- 基于Struts2开发校园二手购物商城源码
开发环境: Windows操作系统开发工具: MyEclipse+Jdk+Tomcat+MySQL数据库 次项目分为管理员和普通用户两种角色 运行效果图 源码及原文链接:https://javadao ...
- Windows10访问Ubuntu子系统(WSL)的桌面环境
原文地址:https://blog.csdn.net/xmh19936688/article/details/90212960 Windows10访问Ubuntu子系统(WSL)的桌面环境文章目录Wi ...
- AI Web 1.0
kali:192.168.0.103 目标机:192.168.0.105 0X01 端口和目录扫描 打开目标主页没有任何信息 a) 端口扫描 只有一个80端口开启 b) 目录扫描 0x03 查看敏感目 ...