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.

题意:

三个数分别转十三进制

AC代码:

#include <iostream>
using namespace std;
int main(){
char ans[];
for(int i=;i<;i++) ans[i]=i+'';
ans[]='A',ans[]='B',ans[]='C';
int a[];
for(int i=;i<;i++) cin>>a[i];
cout<<"#";
for(int i=;i<;i++){
cout<<ans[a[i]/]<<ans[a[i]%];
}
return ;
}
#include<bits/stdc++.h>
using namespace std;
char d[]={'','','','','','','','','','','A','B','C'};
int main(){
int a[];
cin>>a[]>>a[]>>a[];
cout<<"#";
for(int i=;i<=;i++)
{
int x=a[i];
int b[];
int k=;
//转成13进制
while(x>=){
b[++k] = x/;
x=x%;
}
b[++k]=x;
if(k==){
cout<<<<d[b[]];
}else{
cout<<d[b[]]<<d[b[]];
}
}
return ;
}

PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)的更多相关文章

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

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

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

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

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

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

  7. PAT 甲级 1144 The Missing Number (20 分)(简单,最后一个测试点没过由于开的数组没必要大于N)

    1144 The Missing Number (20 分)   Given N integers, you are supposed to find the smallest positive in ...

  8. PAT 甲级 1015 Reversible Primes (20 分) (进制转换和素数判断(错因为忘了=))

    1015 Reversible Primes (20 分)   A reversible prime in any number system is a prime whose "rever ...

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

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

随机推荐

  1. linux 服务器常规巡检并生成报表(一)

    背景 最近接到一个需求要求每天巡检各台业务设备,并导出报表,但一想到设备有N台,一台台每天巡检这样的重复劳作实在是太伤神了,因此决定写一个脚本来搞定这件事. 首先,第一个要解决的问题是批量服务器执行命 ...

  2. c++初步认识

    经过漫长的C学习终于踏入C++的知识库当中了,还是保持以前的习惯会一步步通过写博客的形式来记录点滴学习记录,这种学习方式是相当慢的,但是对我来说是最踏实的,不浮躁,一步一个脚印.C++是一门啥语言呢, ...

  3. (二)AppScan使用教程

    1.新建扫描:一般选择 常规扫描 2.选择扫描的平台:web或app 3.扫描配置向导 ①配置URL和服务器 ②配置登录管理 在扫描的过程中,可能会不小心碰到退出按钮导致Appscan注销.因此,要登 ...

  4. Java并发包--LinkedBlockingDeque

    转载请注明出处:http://www.cnblogs.com/skywang12345/p/3503480.html LinkedBlockingDeque介绍 LinkedBlockingDeque ...

  5. C# GridView 的使用

    1.GridView无代码分页排序: 1.AllowSorting设为True,aspx代码中是AllowSorting="True":2.默认1页10条,如果要修改每页条数,修改 ...

  6. springAop Schedule,注解annotation 实现任务监控

    我们有很多定时任务在任务工程中执行,但是如果我们不加以监控,很有可能定时任务死掉或者卡住我们都不知道. 所以需要做一个任务监控.监控任务当前执行的状态. 还是那样,先让定时任务启动起来,当前我们使用的 ...

  7. How to connect oracle databse

    1. 下載客戶端Oracle Developer Tools for Visual Studio_32bit 安裝后通過配置tnsnames.ora指定連接 C:\app\user name\prod ...

  8. [Luogu] 软件包管理器

    https://www.luogu.org/problemnew/show/P2146 几乎是一个裸题 #include<cstdio> #include<cstring> # ...

  9. 从 s 点到 t 点的最短路(简单模板)(迪杰斯特拉)

    迪杰斯特拉简单版 #include <bits/stdc++.h> using namespace std; int m,n; const int inf = 0x3f3f3f3f; in ...

  10. Fltiss项目的架构、包名的定义和类的划分

    这是项目的一览 首先Web根目录. 除了WEB-INF以外,还有css,img,js,lib目录,这四者都是静态资源. 由于客户端无法访问WEB-INF下的内容,所以将它们放置在了Web根目录下. 而 ...