【PAT】【Advanced Level】1027. Colors in Mars (20)
来源:互联网 发布:php数组最大长度限制 编辑:程序博客网 时间:2024/06/06 11:48
1027. Colors in Mars (20)
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 Input15 43 71Sample Output
#123456
原题链接:
https://www.patest.cn/contests/pat-a-practise/1027
思路:
按要求分解即可
CODE:
#include<iostream>#include<cstring>#include<string>using namespace std;int main(){ char s[13]={'0','1','2','3','4','5','6','7','8','9','A','B','C'}; int r[3]; for (int i=0;i<3;i++) cin>>r[i]; string re=""; re+='#'; for (int i=0;i<3;i++) { re+=s[r[i]/13]; re+=s[r[i]%13]; } cout<<re; return 0;}
- 1027. Colors in Mars (20) @ PAT (Advanced Level) Practise
- 【c++】PAT (Advanced Level)1027. Colors in Mars (20)
- 【PAT (Advanced Level)】1027. Colors in Mars (20)
- 浙大 PAT Advanced level 1027. Colors in Mars (20)
- 【PAT】【Advanced Level】1027. Colors in Mars (20)
- [PAT (Advanced Level) ]1027. Colors in Mars 解题文档
- PAT (Advanced Level) Practise 1027 Colors in Mars (20)
- PAT (Advanced Level) Practise 1027 Colors in Mars (20)
- PAT (Advanced Level) 1027. Colors in Mars (20) 进制转换
- 1027. Colors in Mars (20)【进制转换】——PAT (Advanced Level) Practise
- Pat(Advanced Level)Practice--1027(Colors in Mars)
- PAT-PAT (Advanced Level) Practise 1027. Colors in Mars (20) (简单进制转换)【一星级】
- 1027. Colors in Mars (20)-PAT
- 【PAT】1027. Colors in Mars (20)
- PAT 1027. Colors in Mars (20)
- PAT A 1027. Colors in Mars (20)
- PAT 1027. Colors in Mars (20)
- PAT 1027. Colors in Mars (20)
- Android全沉浸式的方式
- keil ucosiii工程改为 iar工程
- WebService与使用风格RPC/SOA/REST
- Python: decorator
- python基础之numpy
- 【PAT】【Advanced Level】1027. Colors in Mars (20)
- 下一代 Web 应用模型 —— Progressive Web App
- 解决远程连接mysql错误1130 远程连接Mysql服务器的数据库,错误代码是1130,ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to co
- centos上GITLAB的搭建
- 读书笔记:Android开发艺术探索之第6章 android的Drawable
- STL算法之count. count_if
- SpringMVC导出CSV文件中文出现乱码解决方案
- Spring 依赖注入
- 【数据结构】有序树和无序树的区别