题目:http://pat.zju.edu.cn/contests/pat-a-practise/1027
简单题,考察十进制数和n进制数的转换和输出格式的控制。
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
#include<iostream>
#include<string.h>
using namespace std; char red[2];
char green[2];
char blue[2]; void change(int a,char color[2],int base)
{
int i=0;
do
{
if( (a%base)<10 )
color[i++] = ((a%base) + '0');
else
color[i++] = (a%base) + 'A' - 10;
a /= base;
} while (a != 0);
} int main()
{
memset(red,'0',sizeof(red));
memset(green,'0',sizeof(green));
memset(blue,'0',sizeof(blue));
int base = 13;
int a,b,c;
int n;
cin>>a>>b>>c;
change(a,red,base);
change(b,green,base);
change(c,blue,base);
cout<<"#";
cout<<red[1]<<red[0];
cout<<green[1]<<green[0];
cout<<blue[1]<<blue[0]<<endl; return 0;
}
1027. Colors in Mars (20) PAT的更多相关文章
-
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 ...
-
PAT Advanced 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
-
PAT (Advanced Level) Practice 1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
-
PAT (Advanced Level) 1027. Colors in Mars (20)
简单题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
-
PAT甲题题解-1027. Colors in Mars (20)-水。。。
#include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...
-
【PAT甲级】1027 Colors in Mars (20 分)
题意: 输入三个范围为0~168的整数,将它们从十三进制转化为十进制然后前缀#输出. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include& ...
-
1027 Colors in Mars (20 分)
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
-
1027	Colors in Mars (20)
#include <stdio.h> #include <map> using namespace std; int main() { int R,G,B,i; map< ...
随机推荐
-
Web APi之Web Host消息处理管道(六)
前言 我们知道Web API本身是无法提供请求-响应的机制,它是通过Web Host以及Self Host的寄宿的宿主方式来提供一个请求-响应的运行环境.二者都是将请求和响应抽象成HttpRespon ...
-
php大力力 [018节]如何联系大力力
有事儿就注册博客园,给我发 博客园站内的 短消息呗,唉,没有人联系我呀,啦啦啦,爱我爱我,快点爱我 2015-08-26 php大力力018.如何联系大力力
-
iconv内容,convmv文件名,unix2dos,dos2unix文件格式转换,od/cut/wc/dd/diff/uniq/nice/du等命令,linux文件名乱码,文件名,文件内容,vim编码设置
1.enconv文件名编码转换,比如要将一个GBK编码的文件转换成UTF-8编码,操作如下 enconv -L zh_CN -x UTF-8 filename enconv -L GB2312 -x ...
-
一步步优化JVM五:优化延迟或者响应时间
本节的目标是做一些优化以满足对应用对延迟的需求.这次需要几个步骤,包括完善Java堆大小的配置,评估垃圾回收占用的时间和频率,也许还要尝试切换到不同的垃圾回收器,以及由于使用了不同的垃圾回收器,需要重 ...
-
SpringMVC框架学习笔记(5)——数据处理
1.提交数据的处理 a)提交的域名称和参数名称一致 http://localhost:8080/foward/hello.do?name=zhangsan 处理方法 @RequestMapping(v ...
-
关于jvm的OutOfMemory:PermGen space异常的解决
在做网校的时候,经常会在控制台会报出方法区的内存溢出,在网上找的方法,无非都是在tomcat的bin/catalina.bat文件中 设置jvm的堆的大小和方法区的大小,但是通过eclipse启动to ...
-
css入门第一天
一丶Web标准Web标准不是某一个标准,而是一系列标准的集合,内容与结构与表现形式的分离网页主要有四个部分组成:内容(content),结构(structure), 表现(presentation)和 ...
-
request 和 response 对象
Request 对象 request 对象表示 HTTP 请求,包含了请求查询字符串,参数,内容,HTTP 头部等属性 常见属性 /* req.app:当callback为外部文件时,用req.app ...
-
ACM题集以及各种总结大全(转)
ACM题集以及各种总结大全! 虽然退役了,但是整理一下,供小弟小妹们以后切题方便一些,但由于近来考试太多,顾退役总结延迟一段时间再写!先写一下各种分类和题集,欢迎各位大牛路过指正. 一.ACM入门 关 ...
-
在Altium Designer 10中实现元器件旋转45&#176;角放置
Tool--->Preferences >> PCB Editor >> General 将Rotation Step(旋转的步进值)由90改为45,这样以后每次按空格键 ...