PAT 1027 Colors in Mars[简单][注意]
1027 Colors in Mars (20)(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 Input
15 43 71
Sample Output
#123456
题目大意:将输入的三个数分别转换为13进制,然后#输出,并且需要大写。
#include <stdio.h>
#include<iostream>
#include <algorithm>
using namespace std;
char a[];
int main() {
int b[];
for(int i=;i<;i++)
cin>>b[i];
for(int i=;i<;i++){
a[*i+]=(b[i]%>=)?'A'+(b[i]%-):b[i]%+'';
b[i]=b[i]/;
a[*i]=(b[i]%>=)?'A'+(b[i]%-):b[i]%+'';
}
cout<<'#';
for(int i=;i<;i++)
cout<<a[i]; return ;
}
//我真是醉了,我这一个简简单单的代码,居然提交了好几次。。完全都没考虑清楚。
b[i]被新赋值为/,而不是%13.。。判断的时候不是三元表达式出了问题,而是判断应该>=10.注意有=号!!!太马虎了,这是为什么呢?
PAT 1027 Colors in Mars[简单][注意]的更多相关文章
- PAT 1027 Colors in Mars
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- pat 1027 Colors in Mars(20 分)
1027 Colors in Mars(20 分) People in Mars represent the colors in their computers in a similar way as ...
- PAT 甲级 1027 Colors in Mars (20 分)(简单,进制转换)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way ...
- PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分) 凌宸1642 题目描述: People in Mars represent the c ...
- PAT 甲级 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- PAT甲级——1027 Colors in Mars
1027 Colors in Mars People in Mars represent the colors in their computers in a similar way as the E ...
- 1027 Colors in Mars (20 分)
1027 Colors in Mars (20 分) People in Mars represent the colors in their computers in a similar way a ...
- PTA (Advanced Level) 1027 Colors in Mars
Colors in Mars People in Mars represent the colors in their computers in a similar way as the Earth ...
- 1027. Colors in Mars (20) PAT
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1027 简单题,考察十进制数和n进制数的转换和输出格式的控制. People in Mars rep ...
随机推荐
- Material Design系列第八篇——Creating Lists and Cards
Creating Lists and Cards //创建列表和卡片 To create complex lists and cards with material design styles in ...
- 【Linux】python 2.x 升级 python3.x 之后 yum命令出现except OSError, e: ^ SyntaxError: invalid syntax
python2.7升级到python3.6.4 文章链接 : https://zhuanlan.zhihu.com/p/33660059 我在服务器上.把linux默认安装的python2.7 升级 ...
- MAC ox下配置mysql
下载MySQL安装包:http://dev.mysql.com/downloads/mysql/ 如图,选择dmg包,下载完成,双击后打开对应的pkg包,一直点击下一步,直到安装成功 启动和停止MyS ...
- fs-extra 文件管理
一.fs-extra 文件管理 $npm install fs-extra --save 1.创建一个目录 fs.mkdir(path, [mode], [callback(err)]) path 将 ...
- CentOS 安装PostregSQL9.2 同时出现pg安装错误
错误: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/local/bin ...
- PHP服务器访问优化
常规的优化措施: 磁盘写入,网络安全,证书加密,CPU,内存,DNS解析,数据库优化,页面gzip压缩 PHP gzip压缩打开: 打开php目录下的php.ini文件,找到zlib.output_c ...
- Linux下openoffice与SWFtools的安装
第一部份:OpenOffice的安装 1.Openoffice的官网:http://www.openoffice.org/download/index.html 选择Linux 64-bit(x860 ...
- Linux 常用命令标记
1.linux 服务器之间拷贝文件 scp 本地用户名@IP地址:文件名1 远程用户名@IP地址:文件名2 该命令可以变型为目的服务器204上输入如下命令:红色部分是需要接受目的地,-r是递归复制该文 ...
- 字符串-回文-Manacher算法
http://blog.csdn.net/zzkksunboy/article/details/72600679 https://segmentfault.com/a/1190000008484167 ...
- 10W年薪和30W+年薪的产品经理差距在哪?
举办到今年第六届壹佰案例峰会,认识的“程序猿/媛”朋友越来越多,时间长了就发现,程序员的世界一点也不单调,外界传说的不善言辞.最大的乐趣就是买“机械键盘”都是不对的.你见过周末组团去山里骑哈雷的研发经 ...