大连赛区现场赛D题 ZOJ 3542 Hexadecimal View
2011-10-02 20:53
369 查看
大连赛区现场赛最水的一题吧,没什么好说的,简单的模拟题,对于每一行内容,每次取16个字符出来进行处理,输出分成三部分处理会清晰一点。稍微注意下细节就是了
代码写的比较丑,大牛们就飞过吧~
代码写的比较丑,大牛们就飞过吧~
#include <string> #include <cstdio> #include <iostream> #include <vector> #include <cctype> #include <cstring> #include <algorithm> using namespace std; string s; int tot; void print_x(string s1) { int cnt = 0; for (int i=0; i<s1.length(); i++) { printf("%02x", int(s1[i])); cnt++; if (!(cnt&1)) printf(" "); } while (cnt < 16) { printf(" "); cnt++; if (!(cnt&1)) printf(" "); } } void print_s(string s1) { for (int i=0; i<s1.length(); i++) if (isalpha(s1[i])) { if (isupper(s1[i])) printf("%c", tolower(s1[i])); else printf("%c", toupper(s1[i])); } else printf("%c", s1[i]); printf("\n"); } int main() { string st; while (getline(cin, s)) { tot = 0; while (s != "") { printf("%04x: ", tot); if (s.length() >= 16) { st = s.substr(0, 16); s.erase(0, 16); } else { st = s; s.clear(); } print_x(st); print_s(st); tot+=16; } } return 0; }
相关文章推荐
- ZOJ 3542 2011大连现场赛D题(简单模拟)
- ZOJ 3542 2011大连现场赛D题(简单模拟)
- ZOJ 3542 Hexadecimal View [2011大连现场赛]
- ZOJ 3657 The Little Girl who Picks Mushrooms 第37届ACM/ICPC长春赛区现场赛C题(水题)
- 2011年第36届大连赛区现场赛Board
- 2011 ACM/ICPC 大连赛区现场赛题解:Compress the String
- 2016acmicpc现场赛大连赛区D题
- ZOJ 3665 Yukari's Birthday 第37届ACM/ICPC长春赛区现场赛K题 (水题,枚举,二分)
- zoj 3659 第37届ACM/ICPC 长春赛区现场赛E题 (并查集)
- ZOJ 3664 Split the Rectangle 第37届ACM/ICPC长春赛区现场赛 J 题(模拟建树,暴力 求LCA)
- 2014年ACM牡丹江赛区现场赛K题(ZOJ 3829)
- ZOJ 3732 2013 ACM/ICPC 长沙赛区现场赛G题 Graph Reconstruction (图论)
- Hexadecimal View (2011ACM亚洲大连赛区现场赛D题)
- ZOJ 3547 The Boss on Mars 2011大连现场赛I题 数论
- 第一次参加acm-icpc现场赛(2016大连赛区)总结
- ZOJ 3656 Bit Magic 第37届ACM/ICPC长春赛区现场赛B题 (2-SAT)
- HDU 4115 Eliminate the Conflict (2011年成都赛区现场赛E题)
- 大连赛区网络赛部分题目解题报告
- 2013 ACM/ICPC 长沙现场赛 C题 - Collision (ZOJ 3728)
- 2011ACM成都赛区现场赛E题 (2-sat) (SPOJ9939)