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>
#include<stdlib.h>
#include<vector>
#include<algorithm>
using namespace std;
char num[] = { '','','','','','','','','','','A','B','C' }; int main()
{
int color[];
string a = "";
int j = ;
for (int i = ; i < ; i++)
{
j = i*;
cin >> color[i];
int temp = color[i];
while (temp)
{
a[j++]= num[temp % ];
temp /= ;
}
}
cout << "#";
for (int j = ; j < ; j += )
cout << a[j] << a[j - ];
return ;
}

1027 Colors in Mars (20 分)的更多相关文章

  1. PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)

    1027 Colors in Mars (20 分)   People in Mars represent the colors in their computers in a similar way ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 【PAT甲级】1027 Colors in Mars (20 分)

    题意: 输入三个范围为0~168的整数,将它们从十三进制转化为十进制然后前缀#输出. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include& ...

  6. 1027. Colors in Mars (20) PAT

    题目:http://pat.zju.edu.cn/contests/pat-a-practise/1027 简单题,考察十进制数和n进制数的转换和输出格式的控制. People in Mars rep ...

  7. PAT1027 Colors in Mars (20分) 10进制转13进制

    题目 People in Mars represent the colors in their computers in a similar way as the Earth people. That ...

  8. 1027 Colors in Mars (20)

    #include <stdio.h> #include <map> using namespace std; int main() { int R,G,B,i; map< ...

  9. PAT (Advanced Level) 1027. Colors in Mars (20)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...

随机推荐

  1. 《JavaScript 模式》读书笔记(1)— 简介

    哇,看了自己最近的一篇文章,其实那时候刚接触Jest,啥也不会(虽然现在其实也一样不会,嘿嘿),就像记录下工作中遇到的一些问题,其实,后来的一些发现吧,那两篇文章写的其实是有一些问题的.希望不会给大家 ...

  2. python学习-练习题兔子生长问题巩固

    有一对兔子,一个月之后成熟,成熟之后每个月会生出一对兔子,理想状态下兔子不会死,请问n个月后有多少兔子? 分析:第一个月:1 第二个月:1 第三个月:2 第四个月:3 第五个月:5 第六个月:8 从前 ...

  3. C#委托和事件的简单实例

    委托 C#里这个委托我的理解是可以看成是一个方法模板的类型.(不过并没有找到相关的理解 比如有几个返回值,参数列表类型相同的方法,就能用同个模板类型来表示,然后实例化一个委托类型就绑定上一个或多个方法 ...

  4. JAVAEE学习day02

    1.数据类型的转换 1>自动转换(隐式) // 将取值范围小的数据类型自动提升为取值范围大的类型 // 定义byte类型数据 byte b = 10; // 定义short类型数据 short ...

  5. codecs打开不同步给编码的文件

    实例: with codecs.open(file=源文件,mode='命令',encoding='编(解)码方式') as 命名:

  6. winform不能循环引用,使用接口传值到界面

    public partial class frmMain : Form, IFormManager { 4 public frmMain() { InitializeComponent(); 8 } ...

  7. JavaScript初学者

    学习如逆水行舟,不进则退.要逆流而上,逆战! 学习JavaScript这门语言,作为一个初学者,最重要的就是扎实的基础. 只要有了扎实的功底,在后期的学习中才能来去自如的应对各种逻辑难题 下面我们就来 ...

  8. VMware虚拟机安装Mac OS X 10.12

    VMware Workstation Pro 14 安装Mac OS X 10.12 下面是所需要的补丁工具及镜像 VMware Workstation unlocker-master(OS X 虚拟 ...

  9. bash中的if条件语句报错[: missing `]'

    这是我的一个小demo #!/bin/bash read -p "请输入3个数:" n1 n2 n3 if [ $n1 -gt $n2 ] && [ $n1 -gt ...

  10. POJ1523 Tarjan求割点以及删除割点之后强连通分量的数量

    题目链接:http://poj.org/problem?id=1523 SPF:A Single Point of Failure也就是割点(一个点导致网络之间的不连通),由于给出的图是无向图,所以只 ...