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

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

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. using namespace std;
  6. const int MAXN = 5000;
  7.  
  8. char str[MAXN];
  9.  
  10. int main() {
  11. while (cin.getline(str, 4100)) {
  12. int len = strlen(str);
  13. for (int t = 0; t < len ; t += 16) {
  14. printf("%04x: ", t);
  15. for (int i = t; i < t+16; i += 2) {
  16. if (i < len)
  17. printf("%02x", str[i]);
  18. else printf(" ");
  19. if (i+1 < len)
  20. printf("%02x", str[i+1]);
  21. else printf(" ");
  22. printf(" ");
  23. }
  24. for (int i = t; i < len && i < t+16; i++) {
  25. if (str[i] >= 'a' && str[i] <= 'z')
  26. printf("%c", str[i]-'a'+'A');
  27. else if (str[i] >= 'A' && str[i] <= 'Z')
  28. printf("%c", str[i]-'A'+'a');
  29. else printf("%c", str[i]);
  30. }
  31. printf("\n");
  32. }
  33. }
  34. return 0;
  35. }

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. ASCII和ASCII扩展表

  2. unity3d 鼠标事件

    using UnityEngine; using System.Collections; public class mouse : MonoBehaviour { //private Vector3 ...

  3. javascript 公历与农历相互转换工具类

    /** * 公历[1900-1-31,2100-12-31]时间区间内的公历.农历互转 * @charset UTF-8 * @Author Jea杨(JJonline@JJonline.Cn) * ...

  4. hdu 2768 Cat vs. Dog 最大独立集 巧妙的建图

    题目分析: 一个人要不是爱狗讨厌猫的人,要不就是爱猫讨厌狗的人.一个人喜欢的动物如果离开,那么他也将离开.问最多留下多少人. 思路: 爱猫和爱狗的人是两个独立的集合.若两个人喜欢和讨厌的动物是一样的, ...

  5. 使用vs2017创建项目并添加到git中

    参考 https://blog.csdn.net/qq373591361/article/details/71194651 https://blog.csdn.net/boonya/article/d ...

  6. 使用一行代码解决IE浏览器兼容问题

    在网站开发中不免因为各种兼容问题苦恼,针对兼容问题,其实IE给出了解决方案Google也给出了解决方案 百度也应用了这种方案去解决IE的兼容问题 百度源代码如下 <!Doctype html&g ...

  7. [TJOI2018]xor

    题目大意: 有一棵树,根节点为1.每个点有点权.有两种操作. 1. 求节点x所在子树中点权与y异或的最大值.2. 求x到y的路径上点权与z异或的最大值. 解题思路: 可持久化字典树. 对于第一种操作, ...

  8. [USACO4.2] 草地排水 Drainage Ditches (最大流)

    题目背景 在农夫约翰的农场上,每逢下雨,贝茜最喜欢的三叶草地就积聚了一潭水.这意味着草地被水淹没了,并且小草要继续生长还要花相当长一段时间.因此,农夫约翰修建了一套排水系统来使贝茜的草地免除被大水淹没 ...

  9. openblas下载安装与使用

    openblas下载 官方地址 zip文件 tar文件 openblas安装 直接执行 git clone https://github.com/xianyi/OpenBLAS.git cd Open ...

  10. Python面向对象----多态和鸭子类型

    1. C#中多态实现的条件是 继承, 重写以及父类指向子类. 但是在弱类型Python里面, 实现多态的条件就显得很简洁, 只需要在子类中实现父类相同名称的方法即可. 2. 鸭子类型的解释: 若一个类 ...