题意:按要求输出。第一列是表示第几行。每行仅仅能有16个字节的字母,第二列是16进制的ASCII码。第三列大写和小写转换

思路:纯模拟,注意字母的十六进制是2位

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 5000; char str[MAXN]; int main() {
while (cin.getline(str, 4100)) {
int len = strlen(str);
for (int 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(" ");
printf(" ");
}
for (int i = t; i < len && i < t+16; 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;
}

HDU - 4054 Hexadecimal View (2011 Asia Dalian Regional Contest)的更多相关文章

  1. HDU 4115 Eliminate the Conflict(2-SAT)(2011 Asia ChengDu Regional Contest)

    Problem Description Conflicts are everywhere in the world, from the young to the elderly, from famil ...

  2. HDU-4432-Sum of divisors ( 2012 Asia Tianjin Regional Contest )

    Sum of divisors Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  3. HDU 3696 Farm Game(拓扑+DP)(2010 Asia Fuzhou Regional Contest)

    Description “Farm Game” is one of the most popular games in online community. In the community each ...

  4. UVALive 7147 World Cup(数学+贪心)(2014 Asia Shanghai Regional Contest)

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...

  5. ZOJ 3545 Rescue the Rabbit(AC自动机+状压DP)(The 2011 ACM-ICPC Asia Dalian Regional Contest)

    Dr. X is a biologist, who likes rabbits very much and can do everything for them. 2012 is coming, an ...

  6. HDU 3695 / POJ 3987 Computer Virus on Planet Pandora(AC自动机)(2010 Asia Fuzhou Regional Contest)

    Description Aliens on planet Pandora also write computer programs like us. Their programs only consi ...

  7. HDU 4436 str2int(后缀自动机)(2012 Asia Tianjin Regional Contest)

    Problem Description In this problem, you are given several strings that contain only digits from '0' ...

  8. HDU 3685 Rotational Painting(多边形质心+凸包)(2010 Asia Hangzhou Regional Contest)

    Problem Description Josh Lyman is a gifted painter. One of his great works is a glass painting. He c ...

  9. HDU 3686 Traffic Real Time Query System(双连通分量缩点+LCA)(2010 Asia Hangzhou Regional Contest)

    Problem Description City C is really a nightmare of all drivers for its traffic jams. To solve the t ...

随机推荐

  1. C++ 指针 引用 变量引用

    变量引用: 引用的作用就是给变量起个别名,假如有一个变量a,想给它起个别名b,         可以这么写:int a;//定义a是整型变量.int &b=a;//声明b是a的引用. 上面就是 ...

  2. LeetCode Weekly Contest 24

    1, 543. Diameter of Binary Tree 维护左右子树的高度,同时更新结果,返回以该节点结束的最大长度.递归调用. /** * Definition for a binary t ...

  3. c语言return与exit的区别

    2013-09-0918:54:33 exit函数在头文件stdlib.h中,函数原型: void exit(int status); exit(0) 正常运行程序并退出程序. exit(1) 非正常 ...

  4. awk杂集-20170911

    awk 格式 1.awk -F '分割符' 'BEGIN{} /执行条件/{} END{}' filepath; 默认使用空格分割 2.awk -v word=$command '{print wor ...

  5. 全面改造升级内部OA系统

    项目功能集团的OA办公系统,分别是销售管理系统.财务付款系统.原料采购系统.成品采购系统.担保系统和库房管理系统业务现状成品采购系统.库房管理系统.销售管理系统是Access开发的C/S系统,采用本地 ...

  6. svn SSL 错误:Key usage violation in certificate has been detected

    CentOS/RHEL yum 安装的 subversion 是 1.6.11 版本,连VisualSVN服务器时会有"Key usage violation"的错误 将subve ...

  7. 关于 Windows 10 如何扩展分区与合并分区

    前言 相信大部分人都遇见磁盘不够用的问题吧,然后都在后悔当初为什么就给 x 盘分了 10G 的容量吧. 不过没关系,自从 Windows 7 开始( xp 我也不知道有毛有),Windows 自带的磁 ...

  8. 是时候学习 RxSwift 了

    相信在过去的一段时间里,对 RxSwift 多少有过接触或耳闻,或者已经积累了不少实战经验.此文主要针对那些在门口徘徊,想进又拍踩坑的同学. 为什么要学习 RxSwift 当决定做一件事情时,至少要知 ...

  9. 解读:20大5G关键技术

    解读:20大5G关键技术 5G网络技术主要分为三类:核心网.回传和前传网络.无线接入网. 核心网 核心网关键技术主要包括:网络功能虚拟化(NFV).软件定义网络(SDN).网络切片和多接入边缘计算(M ...

  10. URLLib库使用

    Date: 2019-06-19 Author: Sun urllib ​ 在Python 3以后的版本中,urllib2这个模块已经不单独存在(也就是说当你import urllib2时,系统提示你 ...