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. 实例化Vue时的两种挂载方式el与$mount

    el 与mount 都是挂载. el vue官网的介绍https://cn.vuejs.org/v2/api/#el mount vue官网的介绍 https://cn.vuejs.org/v2/ap ...

  2. JavaEE企业面试问题之JavaWeb

    2.Javaweb阶段 2.1 Ajax你以前用过么?简单介绍一下 AJAX = 异步 JavaScript 和 XML.    AJAX 是一种用于创建快速动态网页的技术. 通过在后台与服务器进行少 ...

  3. VS 项目清理小工具 ClearSolution

    简介 VS项目清理小工具,通过INI配置文件快速清理项目,清除无用的数据库等文件与文件夹,简单实用. 支持平台 Windows 开源许可 ClearSolution 遵循 [Apache 协议],使用 ...

  4. [React Native] Up & Running with React Native & TypeScript

    Create a new application with Typescript: react-native init RNTypeScript --template typescript Then: ...

  5. C#常规开发Windows服务

    .Net平台下开发Windows服务的支持库很多,除了通过标准的Windows服务项目,还有一些优秀的开源架构比如:TopSelf:本文以常规项目为例 一.开发 1.新建[Windows服务] 项目: ...

  6. sublime text 3 3126注册码

    —– BEGIN LICENSE —– Michael Barnes Single User License EA7E-821385 8A353C41 872A0D5C DF9B2950 AFF6F6 ...

  7. DOS窗口启动tomact,运用startup.bat/shutdown.bat命令启动/关闭tomcat

    设置CATALINA_HOME环境变量1.CATALINA_HOME是TOMCAT安装路径的别名,目的是为了方便使用TOMCAT2.计算机>属性>环境变量, 新建环境变量.变量名为CATA ...

  8. leetcode解题报告(2):Remove Duplicates from Sorted ArrayII

    描述 Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For ex ...

  9. Gym - 102307G Graduation 拓扑排序

    Gym - 102307G Graduation  题意:xjl得修够n门课才能毕业,其中有些课是某门课的先行课,并且他精力有限,每学期最多只能修k门课,问xjl最少需要多少学期才能毕业. 首先,正向 ...

  10. NVMe - NB的特性

    翻译一下,纯粹是为了记住这些特性: NVMe provides the following benefits: ● Ultra-low latency 非常低的延迟 ● Very high throu ...