PAT A1027 Colors in Mars (20)
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)的更多相关文章
- A1027 Colors in Mars (20)(20 分)
A1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar ...
- 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 ...
- PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- PAT 1027 Colors in Mars[简单][注意]
1027 Colors in Mars (20)(20 分) People in Mars represent the colors in their computers in a similar w ...
- 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 ...
- PAT 1027 Colors in Mars
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- 1027. Colors in Mars (20) PAT
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1027 简单题,考察十进制数和n进制数的转换和输出格式的控制. People in Mars rep ...
- 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 ...
- PAT甲级——A1027 Colors in Mars
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
随机推荐
- Makefile(三)
在平时使用中,可以使用以下的makefile来编译单独的代码 src = $(wildcard *.c) obj = $(patsubst %.c, %.o, $(src)) CC = gcc CFL ...
- vmware中桥接模式和NAT的区别
桥接模式 在桥接模式下,VMWare虚拟出来的操作系统就像是局域网中的一台独立的主机(主机和虚拟机处于对等地 位),它可以访问网内任何一台机器.在桥接模式下,我们往往需要为虚拟主机配置IP地址.子网掩 ...
- mybatis-puls 字段为null时候的更新问题
在mybatis-puls重设置的全局更新策略 为null的字段忽略更新.但是在某些业务需求下面,可能需要某些字段更新为null值.那么改如何设置 1, 在你的实体属性上面单独添加需要更新nu l l ...
- 在 Go 语言中使用 Session(一)
在上一篇博客 理解Cookie和Session 中,我们了解了 Cookie 和 Session 的一些基础知识,也知道了 Session 的基本原理是由服务端保存一份状态信息(以及它的唯一标识符), ...
- Netfilter 之 钩子函数注册
通过注册流程代码的分析,能够明确钩子函数的注册流程,理解存储钩子函数的数据结构,如下图(点击图片可查看原图): 废话不多说,开始分析: nf_hook_ops是注册的钩子函数的核心结构,字段含义如下所 ...
- How to delete System Profiles for those registered with Red Hat Subscription Management (RHSM)?
Environment Red Hat Customer Portal Certificate Based Subscription Red Hat Subscription Management ( ...
- appium中从activity切换到html
问题:混合开发的app中,会有内嵌的H5页面元素,该如何进行定位操作? 解决思路:appium中的元素定位都是基于android原生控件进行元素定位,而web网页是B/S架构,两者运行环境不同需要进行 ...
- LC 873. Length of Longest Fibonacci Subsequence
A sequence X_1, X_2, ..., X_n is fibonacci-like if: n >= 3 X_i + X_{i+1} = X_{i+2} for all i + 2 ...
- 微信小程序入门---记事本增---删
第一.如何获取input框的值(form表单提交除外) bindinput事件 <input type='text' placeholder="请输入内容" placehol ...
- WebLogic服务器
WebLogic是美国Oracle公司出品的一个application server确切的说是一个基于JAVAEE架构的中间件,BEA WebLogic是用于开发.集成.部署和管理大型分布式Web应用 ...