PAT1027
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
就是,一种颜色用6位数字表示,前两位表示红色,中间两位表示绿色,最后两位表示蓝色。
Blue. The only difference is that they use radix 13 (0-9 and A-C) instead of 16.
只有一点不同就是在,他们使用的是13进制取代了我们的16进制。
Now given a color in three decimal numbers (each between 0 and 168), you are supposed to output their Mars RGB values.
现在给出一个颜色的三个十进制数。每个数字从0-168,你需要输出他们的火星RGB值。
Input
Each input file contains one test case which occupies a line containing the three decimal color values.
输入案例:每个输入文件包含一个测试案例,包含一行,3个十进制颜色值。
Output
For each test case you should output the Mars RGB value in the following format:
对于每一个输出样例,你应该输出一个火星的RGB值,并符合以下的形式:
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.
先输出一个“#”,然后接着输出6位数字,所有的英文字符必须大写。如果只有一个颜色只有一个数字,必须左边加0表示。
Sample Input
15 43 71
Sample Output
#123456
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm> using namespace std; char a[]={
'','','','','','','','','','','A','B','C'
}; int main()
{
int r,g,b;
cin>>r>>g>>b;
cout<<"#"<<a[r/]<<a[r%]<<a[g/]<<a[g%]<<a[b/]<<a[b%]<<endl;
return ;
}
代码简练一些,我觉得这样已经可以算是简练了,很简单的一道题目,学习一下英语吧
PAT1027的更多相关文章
- PAT1027:Colors In Mars
1027. Colors in Mars (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue People ...
- PAT1027. Colors in Mars (20)
#include <iostream> using namespace std; string tbl="0123456789ABC"; int main() { in ...
- PAT1027 Colors in Mars (20分) 10进制转13进制
题目 People in Mars represent the colors in their computers in a similar way as the Earth people. That ...
随机推荐
- 五笔拼音反查精灵 v6.69 绿色版
软件名称:五笔拼音反查精灵 v6.69 绿色版软件语言: 简体中文授权方式: 免费软件应用平台: Win7 / Vista / Win2003 / WinXP / Win2008 软件大小: 197K ...
- mysql建表设置两个默认CURRENT_TIMESTAMP的技巧
转载:http://blog.163.com/user_zhaopeng/blog/static/166022708201252323942430/ 业务场景: 例如用户表,我们需要建一个字段是创 ...
- Spring Timer实现
定时器:继承java.util.TimerTask类实现run方法 package com.zbb.framework.util.timer; import java.util.TimerTask; ...
- URL匹配与req参数解析
通配URL*(可代表任何字符串) 例如: app.get('/test/*', function(req, res){ res.send(req.query.aa); }) '/test/*通配tes ...
- ==、equals、hashCode区别?
[==.equals().hashCode()区别?] 1)== 运算符用来比较两个变量的值是否相等. 即该运算符用于比较变量对应得内存中所存储的数值是否相同,要比较两个基本类型的数据或两个引用变量是 ...
- JS获取当前使用的浏览器名字以及版本号
JS获取当前使用的浏览器名字以及版本号 工作中需要通过JS去获取当前使用的浏览器的名字以及版本号,网上大堆资料都有一个关键词是 navigator.appName,但是这个方法获取的浏览器的名字只有两 ...
- 关于PS的一些总结
1.设计给的图,单独用里边的个别图层 打开图 — 新建一个图层(ctrl+n) — (点开上面的窗口排列-垂直排列,左下边下边自动选择改成图层)—选择移动工具,选中要移动的图层,拉到新建文件夹中. ...
- iOStextView的代理方法展示
UITextView的代理方法 textViewShouldBeginEditing: and textViewDidBeginEditing: - (BOOL)textViewShouldBegin ...
- 50个很棒的Python模块
50个很棒的Python模块 我很喜欢Python,Python具有强大的扩展能力,我列出了50个很棒的Python模块,包含几乎所有的需要:比如Databases,GUIs,Images, Soun ...
- php文件去重复,二维数组筛选
http://www.porter.com/fr/fr/product/648162|Sneakershttp://www.porter.com/fr/fr/product/642115|Bootsh ...