1027 Colors in Mars
笔记:本题属于进制转换,但是考察的重点不在除基取余上,因为转化得到的数只有两位,很容易得到每位上面应该是什么,但是和其他题不同的地方在于,每位可填的不见得是0~9,还包括ABC,这就需要用字符数组而不是整型数组来存放结果,并且最后构造一映射函数,将整数映射到对应的字符。
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;char map[14] = {'0','1','2','3','4','5','6','7','8','9','A','B','C'};char toChar(int n){return map[n];
}int main(){char red[3],green[3],blue[3];int r,g,b;scanf("%d %d %d",&r,&g,&b);red[0] = toChar(r/13);red[1] = toChar(r%13);green[0] = toChar(g/13);green[1] = toChar(g%13);blue[0] = toChar(b/13);blue[1] = toChar(b%13);printf("#%c%c%c%c%c%c",red[0],red[1],green[0],green[1],blue[0],blue[1]);return 0;
}
1027 Colors in Mars相关推荐
- PAT甲级1027 Colors in Mars :[C++题解]进制位
文章目录 题目分析 题目链接 题目分析 就是十进制数转化成13进制,然后数字转化成字符. get函数用来将数字转化成字符. 如果 一位数 就是return x +'0'如果 大于9 就是 return ...
- PAT 甲级 1027 Colors in Mars
1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...
- 浙大PAT甲级1027. Colors in Mars (20)
1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...
- PTA 1027 Colors in Mars(读懂题目意思很重要!!)
题目描述如下: 1027 Colors in Mars (20 point(s)) People in Mars represent the colors in their computers in ...
- pat 1027. Colors in Mars (20)
1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...
- PAT甲级 1027 Colors in Mars (20分)
1027 Colors in Mars (20分) 题目链接:PAT A 1027 题目大意:给出三个十进制数,都是在[0-168]范围内,要求将他们转化为13进制后按顺序输出. 思路分析:非常简单的 ...
- 1027 Colors in Mars (20 分)_20行代码AC
立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 People in Mars represent the colors in their computers in a simil ...
- ZJU PAT 1027 Colors in Mars
http://pat.zju.edu.cn/contests/pat-practise/1027 继续无聊. 数制转换一定不要忘了0. 1 #include <stdio.h> 2 #in ...
- 1027. Colors in Mars
C++语言: Codee#25889 01 /* 02 +++++++++++++++++++++++++++++++++++++++ 03 author: chm 0 ...
最新文章
- python必背内容-【经验分享】学Python必背的初级单词
- Delphi 与 DirectX 之 DelphiX(95): TDIB.x
- 获取apk的package name 和 Activity
- boost::container实现devector选项程序
- 【Android-NCNN-Vulkan】ncnn-vulkan load param model 速度慢
- 《Python Cookbook 3rd》笔记(1.13):通过某个关键字排序一个字典列表
- 2 MyWarCraftStudio v0.6版
- 记一次参加 CrossOver Meetup 的经历
- 基于jetty9 编程构建嵌入式https 服务器
- Android与server通信的方法之中的一个(json)效率不高安全性不好
- signature=efaf25d07c6ea03d7552906c0caee5a8,幼児の認知発達における関係把握の問題
- 讲一个让你们难过很久的故事吧?
- Centos使用yum极速安装Java 1.8
- SQL语句取得最大件数(MSSQL ORACLE Postgre,top rownum,limit)
- 基于图像识别的火灾检测系统设计思路流程
- Perl,第一种后现代计算机语言
- wps公式编辑器文字和公式不对齐
- 商标设计需要注意的要素
- 二十一世纪大学英语读写基础教程学习笔记(原文)——5 - Shipwrecked in Antarctica(沉船南极洲)
- 大数卢卡斯求组合数板子