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. Ubuntu系统---报错Assertion '0' failed

    Ubuntu系统---报错Assertion '0' failed YOLO V3,CUDA Error: out of memory darknet: ./src/cuda.c:36: check_ ...

  2. Ubuntu系统---C++之Eclipse IDE 编译器安装

    Ubuntu系统---C++之Eclipse IDE 编译器安装 Eclipse是一个基于Java的.开放源码的.可扩展的应用开发平台,它为编程人员提供了一流的Java集成开发环境(Integrate ...

  3. React 新特性学习

    1 context 2 contextType 3 lazy 4 suspense 5 memo 6 hooks 7 effect hooks =========== 1 Context 提供了一种方 ...

  4. appium+python 【Mac】UI自动化测试封装框架介绍 <四>---脚本的调试

    优秀的脚本调试定位问题具备的特点: 1.方便调试. 2.运行报错后容易定位出现的问题. 3.日志的记录清晰 4.日志可被存储,一般测试结果的分析在测试之后会进行,那么日志的存储将会为后期的分析问题带来 ...

  5. Spring Boot 之FilterRegistrationBean --支持web Filter 排序的使用(转)

    Spring Boot 之FilterRegistrationBean  --支持web Filter 排序的使用Spring 提供了FilterRegistrationBean类,此类提供setOr ...

  6. MySQL数据库有几种索引?分别是什么?

        5种索引     1.主键索引     2.唯一索引     3.普通索引     4.全文索引     5.联合索引

  7. 爬取前尘无忧python职位信息并保存到mongo数据库

    1.re实现 import re,os import requests from requests.exceptions import RequestException MAX_PAGE = 10 # ...

  8. 002_89C52_Proteus_DAC0832_输出50HZ,正弦波,三角波,矩形波,锯齿波

    (一)非常感谢:89C51与ad0832 输出正弦波,三角波,矩形波,锯齿波 (二)在上面的情况下进行程序的修改,实现50HZ的输出 (三)电路图 (三)输出方波 (四)输出锯齿波 (五)输出三角波 ...

  9. form表单 一个input时 回车自动提交

    问题描述 form表单中,如果当前表单只有一个input输入框时,单击回车会自动提交当前表单. 解决方案 在当前form表单中添加一个隐藏的input, <input style="d ...

  10. IO 的底层实现问题

    最近在看 JAVA NIO 的相关知识,了解一下IO的底层实现原理. IO涉及到的底层的概念大致如下: 1) 缓冲区操作.2) 内核空间与用户空间.3) 虚拟内存.4) 分页技术. 一,虚拟存储器 虚 ...