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.注意有=号!!!太马虎了,这是为什么呢?
最新文章
- .Net程序员之不学Java做安卓开发:Android Studio中的即时调试窗口
- HDU 4865 Peter&#39;s Hobby --概率DP
- Objective-C:Foundation框架-常用类-NSNumber
- BTREE与其它索引的优缺点对比
- Android学习之SharedPreferences类
- java(样品集成框架spring、spring mvc、spring data jpa、hibernate)
- 支付顺序-->;微信支付到公司账户-->;待出票
- Spring学习(17)--- 三种装配Bean方式比较
- feed 流数据请求时机的两个思路
- freemarker声明变量(十)
- Cisco banner 登陆消息提示设置命令详解
- 【Unity Shaders】Transparency —— 透明的cutoff shader
- jmeter5.1测试websocket接口
- zabbix使用客户端和不使用客户端监控指定端口
- macbook查找卸载pkg
- 《centos系列》配置vim编辑器
- luogu2048 [NOI2010]超级钢琴 (优先队列+主席树)
- check the manual that corresponds to your MySQL server version for the right syntax to use near
- Struts2学习笔记04 之 拦截器
- barba.js 优化页面跳转用户体验