AC代码

#include <cstdio>
const int max_n = 1000;
int ans[max_n];
char result[max_n];
char radix[13] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'};
int time = 0;
void change(int a) {
int num = 0;
if(a <= 13) { //根据位数来确定是否需要输出多余的0
result[time++] = '0';
result[time++] = radix[a];
} else {
do {
ans[num++] = a % 13;
a /= 13;
} while(a != 0);
for(int i = num - 1; i >=0; i--) {
result[time++] = radix[ans[i]];
}
}
} int main() {
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif // ONLINE_JUDGE}
int a[3] = {0};
scanf("%d%d%d", &a[0], &a[1], &a[2]);
for(int i = 0; i < 3; i++) {
change(a[i]);
}
printf("#");
for(int i = 0; i < time; i++) {
printf("%c", result[i]);
}
return 0;
}

PAT A1027 Colors in Mars (20)的更多相关文章

  1. A1027 Colors in Mars (20)(20 分)

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

  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 甲级 1027 Colors in Mars (20 分)(简单,进制转换)

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

  4. PAT 1027 Colors in Mars[简单][注意]

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

  5. pat 1027 Colors in Mars(20 分)

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

  6. PAT 1027 Colors in Mars

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

  7. 1027. Colors in Mars (20) PAT

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

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

  9. PAT甲级——A1027 Colors in Mars

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

随机推荐

  1. 如何写出好的PRD(产品需求文档)(转)

    作者:Cherry,2007年进入腾讯公司,一直从事互联网广告产品管理工作,目前在SNG/效果广告平台部从事效果广告的产品运营工作. PRD(Product Requirement Document, ...

  2. 1.5 JAVA的IO操作

    1.5 JAVA的IO操作 参考链接:https://www.runoob.com/java/java-files-io.html 一.JAVA的IO操作 由于JAVA引用外界的数据,或是将自身的数据 ...

  3. Kettle环境的安装

    Kettle是绿色免安装的,下载完解压之后找到Spoon.bat,直接执行就好 欢迎界面 Kettle主要分为转换和作业2类 新建一个转换demo 创建了一个转换demo后,由于是数据抽取,因此我们抽 ...

  4. Oracle数据库本地和远程导入、导出

    exp本地导出与imp本地导入 exp命令: 1 exp username/psw@TEST file=d:test.dmp full=y 2 exp username/psw@TEST file=d ...

  5. Linux设备驱动程序 之 原子操作

    原子整数操作 当共享资源是一个简单的整数值时,可以使用内核提供的一种原子的整数类型,称为atomic_t,定义在<linux/types.h>中,操作定义在<linux/atomic ...

  6. Linux孤儿进程与僵尸进程

    1. 基本概念: 孤儿进程:父进程退出,但是其子进程仍然在运行,那么这些子进程被称为孤儿进程:孤儿进程会被init进程收养,并作善后处理: 僵尸进程:一个已经终止,但是其父进程尚未对齐进行善后处理的进 ...

  7. 数据结构之链表(Linked list)

    1, 无序链表(Unordered linked list) 链表是有若干个数据节点依次链接成的数据结构,如下图所示,每一个数据节点包括包括数据和一个指向下一节点的指针.(python中的list就是 ...

  8. redis---set类型常用命令

    添加元素:sadd key value1 value2 查看指定key包含的元素:smembers key 判断指定元素是否存在于key的value中(0表示不存在,1表示存在):sismember ...

  9. ubuntu下如何安装linaro工具链?

    1. 获取工具链 从此处获取,如: wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64 ...

  10. 创建使用Spring Boot

    Spring Boot 创建项目 Spring Initializr 创建完成会自动下载 解压后 Idea导入 修改国内镜像 网络不够强的话停掉自动更新 build.gradle 加上 reposit ...