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. python 绘制f(x)=x^2

    code import turtle import math turtle.speed() # 画一个平方的函数 turtle.penup() turtle., *) turtle.pendown() ...

  2. Codeforces 1051 D.Bicolorings(DP)

    Codeforces 1051 D.Bicolorings 题意:一个2×n的方格纸,用黑白给格子涂色,要求分出k个连通块,求方案数. 思路:用0,1表示黑白,则第i列可以涂00,01,10,11,( ...

  3. javaweb和数据库的简易商城系统

    这是一个基于Javaweb和数据库的简易商城系统.为大二夏季小学期完成. 目录结构 主要功能截图为: 一.购买用户 1.首页(除此界面其余界面访问需要登录才能进入) 查看商品 添加购物车 查看购物车 ...

  4. CF981D

    CF981D 题意: 给你n个数,要求你分成k堆.每堆的内部加和,每堆之间是相与.问最大的值. 解法: 二进制下最大的数的所有位一定是1,所以贪心去找是否最大一定是正确的. 然后DP记录+贪心就可以A ...

  5. iOS开发-多层嵌套block中如何使用__weak和__strong

    1.关于__weak__weak只能在ARC模式下使用,也只能修饰对象(比如NSString等),不能修饰基本数据类型(比如int等)__weak修饰的对象在block中不可以被重新赋值.__weak ...

  6. 使用docker部署mysql主从复制集群

    一.环境搭建 虚拟机环境:centos7 IP: 启动3个容器,一个是master,端口是3307,另外两个是slaver,端口是3308和3309 docker pull mysql:5.7 doc ...

  7. redis的主从复制原理

    1. 前言 和MySQL主从复制的原因一样,Redis虽然读取写入的速度都特别快,但是也会产生读压力特别大的情况.为了分担读压力,Redis支持主从复制,Redis主从复制可以根据是否是全量分为全量同 ...

  8. React入门----基础篇

    React 背景介绍 React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设 Instagram 的网站.做 ...

  9. LC 718. Maximum Length of Repeated Subarray

    Given two integer arrays A and B, return the maximum length of an subarray that appears in both arra ...

  10. 微信小程序入门---记事本增---删

    第一.如何获取input框的值(form表单提交除外) bindinput事件 <input type='text' placeholder="请输入内容" placehol ...