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 ...
随机推荐
- 1分钟快速制作漂亮的Html5本地记事本
大家好,以前给大家分享过一个五步骤制作精美的HTML5时钟的文章,点击回顾<五步教你制作漂亮精致的HTML时钟>,还有<一分钟教你如何实现唯美的文字描边>:今天给大家分享一个用 ...
- Leetcode题目分类整理
一.数组 8) 双指针 ---- 滑动窗口 例题: 3. Longest Substring Without Repeating Characters 描述:Given a string, find ...
- 提交本地文件至gitlab已有的项目中(更新gitlab)
gitlab代码更新 gitlab官网 1.安装git git官网 官网下载安装,安装过程一直next即可(路径自己选) 2.clone至本机 格式:git clone url(可转到指定目录克隆) ...
- DOM操作的性能优化
DOM操作的真正问题在于 每次操作都会出发布局的改变.DOM树的修改和渲染. React解决了大面积的DOM操作的性能问题,实现了一个虚拟DOM,即virtual DOM,这个我们一条条讲. 所以关于 ...
- GDB之调试器用法
GDB 完成的作用: 启动程序,可以按照工程师自定义的要求随心所欲的运行程序 让被调试的程序在工程师指定的断点处停住,断点可以是条件表达式 当程序被停住时,可以检查此时程序中所发生的事,并追索上文 动 ...
- Go语言中new和make的区别
Go语言中new跟make是内置函数,主要用来创建分配类型内存. new( ) new(T)创建一个没有任何数据的类型为T的实例,并返回该实例的指针: 源码解析 func new func new(T ...
- mha之vip漂移 配置binlog-server备份服务器 Atlas
MHAvip漂移 配置 通过MHA自带脚本方式,管理虚拟IP的漂移 获取管理脚本master_ip_failover cp master_ip_failover /usr/local/bin/ #脚本 ...
- jdk1.8 HashMap源码分析(resize函数)
// 扩容兼初始化 final Node<K, V>[] resize() { Node<K, V>[] oldTab = table; int oldCap = (oldTa ...
- 小D课堂 - 新版本微服务springcloud+Docker教程_6-03 高级篇幅之zuul常用问题分析
笔记 3.高级篇幅之Zuul常用问题分析和网关过滤器原理分析 简介:讲解Zuul网关原理和过滤器生命周期, 1.路由名称定义问题 路由映射重复覆盖问题 ...
- Hive的内部表和外部表