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 ...
随机推荐
- Qt封装百度人脸识别+图像识别
AI技术的发展在最近几年如火如荼,工资待遇也是水涨船高,应用的前景也是非常广阔,去年火起来的人脸识别,今年全国遍地开花,之前封装了下face++的人脸识别等接口,今年看了下百度的AI,还免费了,效果也 ...
- 行逻辑链接的顺序表实现稀疏矩阵的相乘(Java语言描述)
行逻辑链接,带行链接信息.程序有空指针BUG,至今未解决.还是C/C++适合描述算法数据结构.以后复杂的算法还是改用C/C++吧. 有BUG的代码,总有一天会换成没有BUG的. package 行逻辑 ...
- LeetCode 38 Count and Say(字符串规律输出)
题目链接:https://leetcode.com/problems/count-and-say/?tab=Description 1—>11—>21—>1211—>111 ...
- Docker关联使用的一些工具:Clip名字服务(转载)
Clip名字服务 Clip(http://blog.puppeter.com/read.php?7)是一个名字服务C/S架构,它将传统的IP管理维度替换为名字服务即有意义可记忆的String.Clip ...
- 23种设计模式之迭代器模式(Iterator)
迭代器模式是一种对象的行为型模式,提供了一种方法来访问聚合对象,而不用暴露这个对象的内部表示.迭代器模式支持以不同的方式遍历一个聚合对象,复杂的聚合可用多种方法来进行遍历:允许在同一个聚合上可以有多个 ...
- 关于hp proliant sl210t服务器远程iLO接口的管理配置
提到hp proliant sl210t服务器,首先得提到HP ProLiant SL2500,HP ProLiant SL2500 可扩展系统提供了 一个非常密集的解决方案,可在标准 2U 机箱最多 ...
- vue之用法
一.安装 对于新手来说,强烈建议大家使用<script>引入 二. 引入vue.js文件 我们能发现,引入vue.js文件之后,Vue被注册为一个全局的变量,它是一个构造函数. 三.使用V ...
- 搭建本地DNS解析
一.安装Dnsmasq yum install -y dnsmasq 二.安装dig yum install dnsmasq -y 三.编辑配置文件 vim /etc/dnsmasq.conf res ...
- js遍历json对象
原生js遍历json对象 遍历json对象: 无规律: <script> var json = [ {dd:'SB',AA:'东东',re1:123}, {cccc:'dd',lk:'1q ...
- MapReduce部分源码解读(一)
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agree ...