题目描述如下:

1027 Colors in Mars (20 point(s))

People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and the last 2 digits for Blue. The only difference is that they use radix 13 (0-9 and A-C) instead of 16. Now given a color in three decimal numbers (each between 0 and 168), you are supposed to output their Mars RGB values.

Input Specification:

Each input file contains one test case which occupies a line containing the three decimal color values.

Output Specification:

For each test case you should output the Mars RGB value in the following format: first output #, then followed by a 6-digit number where all the English characters must be upper-cased. If a single color is only 1-digit long, you must print a 0 to its left.

Sample Input:

15 43 71

Sample Output:

#123456

遇到的问题与解决思路:

这里的输出格式一定是#打头的,就是按照样例来,它补充说明的“如果有一个颜色是0,那么在它的左边输出0”,比如输入0 0 0,是输出#0 0 0还是#000000又或者是0?

问题就出在这里!

因为你根本没有理解题目在说什么!!!

题目的意思,如果输出的是1 1 1,那么输出的应该是#010101,用0来补位。

所以,根本不是英文的表述问题,这很清晰,而是自己太急,没冷静下来!

具体解决如下:

#include <cstdio>
const char marsnum[13] = {'0', '1', '2', '3', '4', '5', '6','7', '8', '9' , 'A', 'B', 'C'};
int main()
{int deci[3] = {0};int mars[6] = {0};for (int i = 0; i < 3; i++) {scanf("%d", &deci[i]);}int index = 0;for (int i = 0; i < 3; i++) {mars[index + 1] = deci[i] % 13;mars[index] = deci[i] / 13;index += 2;}/*for (int i = 0; i < 6; i++) {printf("%d", mars[i]);}printf("\n");*/printf("#");for (int i = 0; i < 6; i++) {printf("%c", marsnum[mars[i]]);}return 0;
}

PTA 1027 Colors in Mars(读懂题目意思很重要!!)相关推荐

  1. PAT甲级 1027 Colors in Mars (20分)

    1027 Colors in Mars (20分) 题目链接:PAT A 1027 题目大意:给出三个十进制数,都是在[0-168]范围内,要求将他们转化为13进制后按顺序输出. 思路分析:非常简单的 ...

  2. PAT甲级1027 Colors in Mars :[C++题解]进制位

    文章目录 题目分析 题目链接 题目分析 就是十进制数转化成13进制,然后数字转化成字符. get函数用来将数字转化成字符. 如果 一位数 就是return x +'0'如果 大于9 就是 return ...

  3. PAT 甲级 1027 Colors in Mars

    1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...

  4. 浙大PAT甲级1027. Colors in Mars (20)

    1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...

  5. pat 1027. Colors in Mars (20)

    1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...

  6. 1027 Colors in Mars (20 分)_20行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 People in Mars represent the colors in their computers in a simil ...

  7. ZJU PAT 1027 Colors in Mars

    http://pat.zju.edu.cn/contests/pat-practise/1027 继续无聊. 数制转换一定不要忘了0. 1 #include <stdio.h> 2 #in ...

  8. 【PAT甲级 十进制转十三进制】1027 Colors in Mars (20 分) Java版 5/5通过

    题目 是个水题,一次通过. 这道题的大意就是:给你输入3个十进制的数,让你转换成3个十三进制数.在转换的时候,注意不足两位的要用0补全两位. 小坑 提交之前,想起来自查一下我的convert(int ...

  9. 1027 Colors in Mars

    笔记:本题属于进制转换,但是考察的重点不在除基取余上,因为转化得到的数只有两位,很容易得到每位上面应该是什么,但是和其他题不同的地方在于,每位可填的不见得是0~9,还包括ABC,这就需要用字符数组而不 ...

最新文章

  1. R - history
  2. Open vSwitch相关字段详解之L3:IPv4IPv6
  3. Scrum敏捷开发沉思录
  4. javascript select option对象总结
  5. linux下centos安装mysql数据库_Linux CentOS 下的MySQL数据库安装与配置-阿里云开发者社区...
  6. android app的签名,Android APP的签名
  7. 数据结构实验之二叉树五:层序遍历
  8. 数值计算方法(高斯消元以及LU分解)
  9. Android应用资源---其他资源类型(More Types)(二)
  10. 物联网专用卡的优势有哪些
  11. 特征向量的线性无关性
  12. 电影购票c语言程序,C语言电影购票系统小样
  13. 使用Silvaco设计构建NMOS晶体管、PNP、NPN双极型晶体管并提取各项工艺及器件参数:半导体器件和工艺模拟
  14. axure能做剪切蒙版吗_现在做uv打印生意能做吗,好做吗?
  15. HbuilderX如何创建一个新的Vue工程
  16. 短时傅里叶变换STFT(非使用fft函数)
  17. 《无声告白》这不是我想要的生活
  18. HanLP《自然语言处理入门》笔记--1.新手上路
  19. 最短公共超序列(最短公共父序列)
  20. 关于视觉工业相机的50个问题

热门文章

  1. android ios版本 市场占有率,最新的智能移动终端ios,android等市场占有率情况
  2. Ceph中查找BUCKET INDEX所在位置的方法
  3. WebSocket(3)---实现一对一聊天功能
  4. 使用集集快速添加公众号预约功能
  5. 经典面试题之Vue生命周期
  6. The request was rejected because the URL contained a potentially malicious String “;“问题的正确解决姿势
  7. SaaSBase:艺赛旗iS-RPA是什么?
  8. android l风格cm10主题,Android 4.3的CM10.2
  9. jzyzoj 1216 poj虫洞 3259 Bellman_Ford模板
  10. 看个视频就可以日进斗金!Reaction网红,了解一下