PAT Advanced 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>
using namespace std;
char toChar(int a){
switch(a){
case :return 'A';break;
case :return 'B';break;
case :return 'C';break;
default:return a+'';
}
}
int main() {
int a,b,c;
cin>>a>>b>>c;
cout<<"#"<<toChar(a/)<<toChar(a%)<<toChar(b/)<<toChar(b%)<<toChar(c/)<<toChar(c%);
system("pause");
return ;
}
注意大于10进制都需要一个toChar函数
PAT Advanced 1027 Colors in Mars (20 分)的更多相关文章
- PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- 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 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- 【PAT甲级】1027 Colors in Mars (20 分)
题意: 输入三个范围为0~168的整数,将它们从十三进制转化为十进制然后前缀#输出. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include& ...
- 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642
PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...
- 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 People in Mars represent the colors in their computers in a similar way as the E ...
随机推荐
- iOS 自定义一对UI表现相反的按钮
假如有一对按钮[重置][提交],要让他们的默认UI和点击的UI表现刚好相反 [提交]按钮,默认橙色,点击边框是橙色,字体是橙色,背景变白色 [重置]按钮,默认白色橙色,边框是橙色,点击字体是白色,背景 ...
- c/c++运算符
1.算术运算符(+ - / * %) 2.移位运算符 移运算符:操作数必须是整形,>>,逻辑左移左边移入的位用0填充,算数左移左边移入的的位用符号位补齐.(无符号数为逻辑左移,对于 ...
- SQL 2008建一个job
原文地址:http://blog.csdn.net/htl258/article/details/5543694 -- Author : htl258(Tony)-- Date : 2010- ...
- windows下mingw编译faac
进入目录先运行 ./bootstrap 接着就可以 ./configure --without-mp4v2 然后 make make install
- 使用NSIS脚本制作一个安装包
大部分人第一次看到NSIS脚本都是一脸懵逼的.因为它这个脚本的结构乍一看上去就非常奇怪,不作说明的话是看不懂的. 编写脚本命令的时候要非常注意,命令要按照规定写在脚本中不同的段落里,也就是说,命令的先 ...
- Python深度学习读书笔记-2.初识神经网络
MNIST 数据集 包含60 000 张训练图像和10 000 张测试图像,由美国国家标准与技术研究院(National Institute of Standards and Technology,即 ...
- Linux_LVM、RAID_RHEL7
目录 目录 LVM逻辑卷管理 把物理分区初始化为物理卷 创建卷组 建立逻辑卷 格式化 挂载 vg拓展操作 lv扩展操作 RAID RAID 类型 RAID0条带化 RAID1镜像 RAID5条带冗余 ...
- Django开启https(不用nginx)
首先安装需要用到的包 pip install django-extensions pip install django-werkzeug-debugger-runserver pip install ...
- Java ——接口
本节重点思维导图 定义: public interface Traffic { public static final int sits = 4; public abstract void run() ...
- cocos2dx基础篇(11) 点九图CCScale9Sprite
[3.x] (1)去掉"CC" [v3.3] 我们在 ui模块 下实现了一个新的Scale9Sprite类.它的内部实现比之前的Scale9Sprite更为简洁,功能也更为强大. ...