1027. Colors in Mars (20)

时间限制
400 ms

内存限制
65536 kB

代码长度限制
16000 B

判题程序
Standard

作者
CHEN, Yue

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

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

Output

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 the left.

Sample Input

15 43 71

Sample Output

#123456
解:这题意思明确,水题,但是我在这个水题上磕了好久,真丢人。最初我的代码片段是这样的。
<span style="font-family:SimSun;">        string s[3];for(int i=0;i<3;i++){s[i][0]='0';s[i][1]='0';s[i][0]=a[num[i]/13];s[i][1]=a[num[i]%13];}</span>

提交一直有样例不过,当时很郁闷,我个人认为自己还是把这题意思理解透彻了的。后来问了小czy,好的吧,自己用错了,s的范围我还没给定呢,可以用s[i].push_back(char),而不可以像上面的直接用。

代码改成以下,测试通过:
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
char a[13]={'0','1','2','3','4','5','6','7','8','9','A','B','C'};
int main()
{int num[3];while(scanf("%d%d%d",&num[0],&num[1],&num[2])==3){// char s[3][2];string s[3];for(int i=0;i<3;i++){s[i].push_back('0');s[i].push_back('0');s[i][0]=a[num[i]/13];s[i][1]=a[num[i]%13];}cout<<"#";for(int i=0;i<3;i++){cout<<s[i][0]<<s[i][1];s[i].clear();}cout<<endl;}
}

pat 1027. Colors in Mars (20)相关推荐

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

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

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

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

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

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

  4. ZJU PAT 1027 Colors in Mars

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

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

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

  6. PAT 甲级 1027 Colors in Mars

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

  7. PTA 1027 Colors in Mars(读懂题目意思很重要!!)

    题目描述如下: 1027 Colors in Mars (20 point(s)) People in Mars represent the colors in their computers in ...

  8. PAT A1027 Colors in Mars

    有点意思,简单的进制转化,但是实际上有坑 每两位作为一个单位进行处理,每两个都是倒序的,也就是说,15 43 71--->21 43 65,其实只要分三组存储,分开输出即可 //1027 Col ...

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

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

最新文章

  1. c10k问题及其解决方案
  2. 23 duplicate symbols for architecture i386
  3. Sql Server的弱口令入侵测试以及防范
  4. 【2020年第12届全国大学生数学竞赛——资源分享 】【1~11届省赛决赛考题及题解(数学类、非数学类)、推荐学习网址、复习备考书籍推荐】
  5. Hadoop之HDFS概述
  6. centos 7 局域网丢包排查_网络排查神器:mtr
  7. 在sharepoint中添加视频播放
  8. int true python_python基本数据类型,int, str, bool及相关操作
  9. java中断线程_Java线程中断机制-如何中断线程
  10. Ubuntu下解决文件名mp3标签和文本文件内容的乱码问题
  11. 【GEE】配置本地python环境
  12. 笨方法python3_“笨方法”学Python3,习题 30 。
  13. DeBUG|实例化servlet类xxxx异常
  14. execute()方法
  15. python笔试编程题_Python自动化测试笔试面试时常见的编程题
  16. 百度,谷歌,360,搜狗,神马等蜘蛛IP段大全
  17. dedecms模板定制之如何自定义标签
  18. 百度AI语音SDK集成
  19. KDZD606绝缘服试验装置
  20. 安装破解PyCharm 2018.3.x

热门文章

  1. SG-UAP平台 : MX框架总结
  2. 十大最佳Python书籍[2021年更新]
  3. php 爬虫 超市,scrapy爬虫 爬取天猫进口零食网页
  4. json能传数字,不能传字符串
  5. NLP的bigrams函数“generator object bigrams at 0x000001D32A95A678“问题解决
  6. 世界上没有哪一份工作是不受气的,哪怕是老板,也会有受气的时候
  7. python语言玫瑰花_Python 玫瑰花绘制
  8. 晶圆在低温探针台中的安装方式——Cyanoacrylate粘合剂
  9. 起点中文网 字体反爬技术 网页可以显示数字字母 网页代码是乱码或空格
  10. 高德地图API - 根据经纬度获取周边建筑地标