zoukankan      html  css  js  c++  java
  • HDU 4054 Hexadecimal View 模拟

    戳这里:HDU 4054

    //复习一下 cin.getline() 的用法

     1 #include "bits/stdc++.h"
     2 using namespace std;
     3 char str[5000];
     4 
     5 char Change(char c)
     6 {
     7     if('A' <= c && c <= 'Z') {
     8         return c + 32;
     9     }
    10     if('a' <= c && c <= 'z') {
    11         return c - 32;
    12     }
    13     return c;
    14 }
    15 
    16 int main()
    17 {
    18     while(cin.getline(str, 4500)) {
    19         int len = strlen(str);
    20         int row;
    21         for(row = 0; row < len; row += 16) {
    22             printf("%04x: ", row);
    23             int i;
    24             for(i = row; i < row + 16; i += 2) {
    25                 if(i < len)
    26                     printf("%02x", str[i]);
    27                 else
    28                     printf("  ");    //两个空格
    29                 if(i + 1 < len)
    30                     printf("%02x ", str[i + 1]);    //后有一个空格
    31                 else
    32                     printf("   ");    //两个空格
    33             }
    34 
    35             for(i = row; i < row + 16 && i < len; ++i) {
    36                 printf("%c", Change(str[i]));
    37             }
    38             printf("
    ");
    39         }
    40     }
    41 }
  • 相关阅读:
    计算机导论课后总结第二弹
    深入懂得信息
    计算机导论课后总结第一弹
    upload-labs脑图
    高精度学习
    洛谷学习
    Bugku 密码学脑图
    Bypass disabled_functions
    Python库学习
    LFI-labs
  • 原文地址:https://www.cnblogs.com/AC-Phoenix/p/4475122.html
Copyright © 2011-2022 走看看