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. .net core Redis库 CSRedis

    由于servicestack.redis收费,基于有人说StackExchange.Redis 使用会出现一些问题比如会超时, 找到了CSRedis这个库,很强大很实用.另外有兴趣的朋友还可以试试另一 ...

  2. 面试题_Spring基础篇

    Spring基础题 1. 什 么 是 Spring? Spring 是 个 java 企 业 级 应 用 的 开 源 开 发 框 架 .Spring 主 要 用 来 开 发 Java 应 用 , 但 ...

  3. 关于keepalive

    linux内核配置有一项tcp_keepalive_time,即tcp的保活定时器.当网络上两个建立连接的进程都没有数据向对方发送的时候,tcp会隔段时间发送一次保活数据,以保持连接,间隔时间就是tc ...

  4. win10系统配置FTP

    FTP是一种远程传输协议,支持这种协议的就是FTP服务器.我们可以在自己的PC机上创建一个.然后通过网页就可以访问FTP服务器下的文件夹. 搭建过程 1.首先需要开启FTP服务.在菜单中打开控制面板. ...

  5. JS基础_数组的遍历

    遍历:将数组中所有的元素都取出来 1.for循环 var arr = ["1","2","3"]; for(let i=0;i<arr ...

  6. RHEL 7.6系统安装配置图解教程

  7. markdown简单的使用方法

    转自 https://www.cnblogs.com/math/p/se-tools-001.html 作者:正交分解 1.如何切换编辑器 切换博客园编辑器为MarkDown:MarkDown Edi ...

  8. 【Spark机器学习速成宝典】推荐引擎——协同过滤

    目录 推荐模型的分类 ALS交替最小二乘算法:显式矩阵分解 Spark Python代码:显式矩阵分解 ALS交替最小二乘算法:隐式矩阵分解 Spark Python代码:隐式矩阵分解 推荐模型的分类 ...

  9. 前端知识点回顾之重点篇——AJAX

    Ajax(Asynchronous JavaScript and XML) 这种技术就是无须刷新页面即可从服务器中取得数据,但不一定是XML数据.在原生方法上,Ajax技术的核心是XMLHttpReq ...

  10. 009-centos6.6 用户以及组操作

    1.查看用户所属组 id admin uid=500(admin) gid=500(admin) 组=500(admin) 2.查看用户信息 用户列表文件:cat /etc/passwd 查看系统中有 ...