Hexadecimal View (2011ACM亚洲大连赛区现场赛D题)
2011-10-02 13:35
393 查看
Hexadecimal ViewTime Limit: 2 Seconds Memory Limit: 65536 KB
Hexadecimal is very important and useful for computer programmers. You are requested to provide a hexadecimal view for given data. The hexadecimal view is made up of one or more rows. Every row except the last one represents 16 characters. Each row consists of three columns separated by a space:
addr: the 4-digit hexadecimal beginning address of this row.
dump: the hexadecimal representation of this row, separating every two characters by a whitespace. If there are less than 16 characters in the last row, pad it with spaces.
text: the ASCII translation of this row, with uppercase characters converted to lowercase and lowercase characters converted to uppercase.
Use lowercase for the letter digits. See sample for more details.
Author: WU, Zejun
题目比较简单,输入输出注意点。。。
看来要去复习下C++的输入输出的函数了。。。。。
WR了好多次,原来数组太小。题目给的是4096的,我卡的太紧了,,,下次开大点了。。。
C语言的函数轻松过掉
Hexadecimal is very important and useful for computer programmers. You are requested to provide a hexadecimal view for given data. The hexadecimal view is made up of one or more rows. Every row except the last one represents 16 characters. Each row consists of three columns separated by a space:
addr: the 4-digit hexadecimal beginning address of this row.
dump: the hexadecimal representation of this row, separating every two characters by a whitespace. If there are less than 16 characters in the last row, pad it with spaces.
text: the ASCII translation of this row, with uppercase characters converted to lowercase and lowercase characters converted to uppercase.
Use lowercase for the letter digits. See sample for more details.
Input
There are multiple test cases. Each line is a test case. The line is made up of no less than 1 and no more than 4096 printable characters including spaces.Output
For each test case, output its hexadecimal view. Do not output any extra spaces after the last character of text.Sample Input
Hex Dump #include <cstdio> printf("Hello, World!\n"); main = do getLine >>= print . sum . map read . words
Sample Output
0000: 4865 7820 4475 6d70 hEX dUMP 0000: 2369 6e63 6c75 6465 203c 6373 7464 696f #INCLUDE <CSTDIO 0010: 3e > 0000: 7072 696e 7466 2822 4865 6c6c 6f2c 2057 PRINTF("hELLO, w 0010: 6f72 6c64 215c 6e22 293b ORLD!\N"); 0000: 6d61 696e 203d 2064 6f20 6765 744c 696e MAIN = DO GETlIN 0010: 6520 3e3e 3d20 7072 696e 7420 2e20 7375 E >>= PRINT . SU 0020: 6d20 2e20 6d61 7020 7265 6164 202e 2077 M . MAP READ . W 0030: 6f72 6473 ORDS
Author: WU, Zejun
题目比较简单,输入输出注意点。。。
看来要去复习下C++的输入输出的函数了。。。。。
WR了好多次,原来数组太小。题目给的是4096的,我卡的太紧了,,,下次开大点了。。。
C语言的函数轻松过掉
#include<stdio.h> #include<iostream> #include<string.h> #include<iomanip> using namespace std; char str[5000]; int main() { int t=0; int len; while(cin.getline(str,4100))//这里要开大点,错了好几次了 { t=0; len=strlen(str); for(t=0;t<len;t+=16) { printf("%04x: ",t); for(int i=t;i<t+16;i+=2) { if(i<len) printf("%02x",str[i]); else printf(" "); if(i+1<len) printf("%02x ",str[i+1]); else printf(" "); } for(int i=t;i<t+16&&i<len;i++) { if(str[i]>='a'&&str[i]<='z') printf("%c",str[i]-'a'+'A'); else if(str[i]>='A'&&str[i]<='Z') printf("%c",str[i]-'A'+'a'); else printf("%c",str[i]); } printf("\n"); } } return 0; }
相关文章推荐
- 2011 ACM/ICPC 大连赛区现场赛题解:Compress the String
- 2011-第36届ACM/ICPC亚洲区中国大陆5个赛区主办方网络赛和现场赛时间安排
- 2011 ACM亚洲预选赛大连站 现场赛 D题 Hexadecimal View
- 2011 ACM/ICPC 北京赛区现场赛解题:Qin Shi Huang's National Road System
- ACM HDU 4001 To Miss Our Children Time (2011ACM大连赛区网络赛)
- 2011 ACM/ICPC 北京赛区现场赛解题:Activation
- HDU5078 2014 ACM-ICPC亚洲区域赛鞍山赛区现场赛I题 Osu! 签到题
- 2011 ACM/ICPC 北京赛区现场赛解题:GemAnd Prince
- 2014年ACM/ICPC亚洲区现场赛广州赛区总结
- ACM HDU 4004 The Frog's Games(2011ACM大连赛区第四题)
- 2011 ACM/ICPC 北京赛区现场赛解题:Peach Blossom Spring
- 2011 ACM/ICPC 福州赛区现场赛8.7
- ZOJ3822 ACM-ICPC 2014 亚洲区域赛牡丹江赛区现场赛D题Domination 概率DP
- ACM/ICPC 2011 福州赛区现场赛第一题 (A .Xiangqi)
- ZOJ3829 ACM-ICPC 2014 亚洲区域赛牡丹江赛区现场赛K题 Known Notation 贪心
- HDU5074 ACM-ICPC亚洲区域赛鞍山赛区现场赛E题 Hatsune Miku 二维DP
- 第一次参加acm-icpc现场赛(2016大连赛区)总结
- HDU 4004 - The Frog\'s Games 第36届ACM/ICPC亚洲大连赛区网络赛
- 2011 ACM 福州赛区现场赛第一题 (A .Xiangqi)HDU 4121 Xiangqi by kuangbin
- HDU5073 ACM-ICPC亚洲区域赛鞍山赛区现场赛D题 Galaxy 贪心+数学推导