• hdu 4690 EBCDIC


    还有什么好说的呢?打表题= =

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 #include<map>
     5 using namespace std;
     6 
     7 #define MP make_pair
     8 
     9 map < pair <char,char>,pair<char,char> > mm;
    10 
    11 void init()
    12 {
    13     mm[MP('0','0')] = MP('0','0');mm[MP('0','1')] = MP('0','1');mm[MP('0','2')] = MP('0','2');mm[MP('0','3')] = MP('0','3');
    14     mm[MP('3','7')] = MP('0','4');mm[MP('2','D')] = MP('0','5');mm[MP('2','E')] = MP('0','6');mm[MP('2','F')] = MP('0','7');
    15     mm[MP('1','6')] = MP('0','8');mm[MP('0','5')] = MP('0','9');mm[MP('2','5')] = MP('0','A');mm[MP('0','B')] = MP('0','B');
    16     mm[MP('0','C')] = MP('0','C');mm[MP('0','D')] = MP('0','D');mm[MP('0','E')] = MP('0','E');mm[MP('0','F')] = MP('0','F');
    17 
    18     for(int i = '0';i<='3';i++) 
    19             mm[MP('1',i)] = MP('1',i);
    20     mm[MP('3','C')] = MP('1','4');mm[MP('3','D')] = MP('1','5');mm[MP('3','2')] = MP('1','6');mm[MP('2','6')] = MP('1','7');
    21     mm[MP('1','8')] = MP('1','8');mm[MP('1','9')] = MP('1','9');mm[MP('3','F')] = MP('1','A');mm[MP('2','7')] = MP('1','B');
    22     for(int i = 'C';i<='F';i++) 
    23             mm[MP('1',i)] = MP('1',i);
    24 
    25     mm[MP('4','0')] = MP('2','0');mm[MP('5','A')] = MP('2','1');mm[MP('7','F')] = MP('2','2');mm[MP('7','B')] = MP('2','3');
    26     mm[MP('5','B')] = MP('2','4');mm[MP('6','C')] = MP('2','5');mm[MP('5','0')] = MP('2','6');mm[MP('7','D')] = MP('2','7');
    27     mm[MP('4','D')] = MP('2','8');mm[MP('5','D')] = MP('2','9');mm[MP('5','C')] = MP('2','A');mm[MP('4','E')] = MP('2','B');
    28     mm[MP('6','B')] = MP('2','C');mm[MP('6','0')] = MP('2','D');mm[MP('4','B')] = MP('2','E');mm[MP('6','1')] = MP('2','F');
    29 
    30     for(int i = '0';i<='9';i++) 
    31         mm[MP('F',i)] = MP('3',i);
    32     mm[MP('7','A')] = MP('3','A');mm[MP('5','E')] = MP('3','B');mm[MP('4','C')] = MP('3','C');mm[MP('7','E')] = MP('3','D');
    33     mm[MP('6','E')] = MP('3','E');mm[MP('6','F')] = MP('3','F');
    34 
    35     mm[MP('7','C')] = MP('4','0');
    36     for(int i = '1',j = '1';j<='9';j++,i++)
    37         mm[MP('C',i)] = MP('4',j);
    38     for(int i = '1',j = 'A';j<='F';i++,j++)
    39         mm[MP('D',i)] = MP('4',j);
    40 
    41     for(int i = '7',j = '0';j<='2';i++,j++)
    42         mm[MP('D',i)] = MP('5',j);
    43     for(int i = '2',j = '3';j<='9';i++,j++)
    44         mm[MP('E',i)] = MP('5',j);
    45     mm[MP('E','9')] = MP('5','A');mm[MP('B','A')] = MP('5','B');mm[MP('E','0')] = MP('5','C');mm[MP('B','B')] = MP('5','D');
    46     mm[MP('B','0')] = MP('5','E');mm[MP('6','D')] = MP('5','F');
    47 
    48     mm[MP('7','9')] = MP('6','0');
    49     for(int i = '1',j = '1';i<='9';i++,j++)
    50         mm[MP('8',i)] = MP('6',j);
    51     for(int i = '1', j = 'A';j<='F';i++,j++)
    52         mm[MP('9',i)] = MP('6',j);
    53 
    54     for(int i = '7',j = '0';j<='2';i++,j++)
    55         mm[MP('9',i)] = MP('7',j);
    56     for(int i = '2',j = '3';j<='9';i++,j++)
    57         mm[MP('A',i)] = MP('7',j);
    58     mm[MP('A','9')] = MP('7','A');mm[MP('C','0')] = MP('7','B');mm[MP('4','F')] = MP('7','C');mm[MP('D','0')] = MP('7','D');
    59     mm[MP('A','1')] = MP('7','E');mm[MP('0','7')] = MP('7','F');
    60 }
    61 
    62 const int MAXN = 11111111;
    63 
    64 char str[MAXN];
    65 
    66 int main()
    67 {
    68     init();
    69     while(~scanf("%s",str))
    70     {
    71         int len = strlen(str);
    72         for(int i = 0;i<len;i += 2)
    73         {
    74             if(mm.find(MP(str[i],str[i+1]))!=mm.end())
    75                 printf("%c%c",mm[MP(str[i],str[i+1])].first,mm[MP(str[i],str[i+1])].second);
    76         }
    77 
    78         puts("");
    79     }
    80     return 0;
    81 }
    View Code
  • 相关阅读:
    linux 文件权限(s、t、i、a)解析
    vim Vundle
    数据结构学习(1)
    Android ImageView设置图片原理(上)
    C++11 之auto
    Android屏幕分辨率获取方法--源码剖析
    C++的发展方向是对的嘛?
    c++ 的前世今生
    学习知识的一种思路
    遗失的访谈小评
  • 原文地址:https://www.cnblogs.com/zstu-abc/p/3270600.html
Copyright © 2020-2023  润新知