HDU 4690 EBCDIC (2013多校 1005题 胡搞题)

 

EBCDIC

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)
Total Submission(s): 160    Accepted Submission(s): 81

Problem Description A mad scientist found an ancient message from an obsolete IBN System/360 mainframe. He believes that this message contains some very important secret about the Stein’s Windows Project. The IBN System/360 mainframe uses Extended Binary Coded Decimal Interchange Code (EBCDIC). But his Artificial Intelligence Personal Computer (AIPC) only supports American Standard Code for Information Interchange (ASCII). To read the message, the mad scientist ask you, his assistant, to convert it from EBCDIC to ASCII.

Here is the EBCDIC table.

      

Here is the ASCII table.

 

 

Input The input of this problem is a line of uppercase hexadecimal string of even length. Every two hexadecimal digits stands for a character in EBCDIC, for example, “88” stands for ‘h’.  

 

Output Convert the input from EBCDIC to ASCII, and output it in the same format as the input.  

 

Sample Input C59340D7A2A840C3969587999696  

 

Sample Output 456C2050737920436F6E67726F6F
Hint E.html download 方便图中文字复制 http://pan.baidu.com/share/link?shareid=453447595&uk=352484775  

 

Author Zejun Wu (watashi)  

 

Source
2013 Multi-University Training Contest 9  

 

Recommend zhuyuanchen520  

 

 

 

 

这题胡搞就行了。

 

 

把上面的和下面的表都复制下来。  注意上面的空的要找个东西代替。

 

在记事本下很容易修改了。查找替换啥的,再手动修改下格式

 

 1 /* ***********************************************
 2 Author        :kuangbin
 3 Created Time  :2013/8/20 13:11:33
 4 File Name     :F:\2013ACM练习\2013多校9\1005.cpp
 5 ************************************************ */
 6 
 7 #include <stdio.h>
 8 #include <string.h>
 9 #include <iostream>
10 #include <algorithm>
11 #include <vector>
12 #include <queue>
13 #include <set>
14 #include <map>
15 #include <string>
16 #include <math.h>
17 #include <stdlib.h>
18 #include <time.h>
19 using namespace std;
20 string str[] =
21 {
22 "NUL","SOH","STX","ETX","XXXXXXX","HT","XXXXXXX","DEL","XXXXXXX","XXXXXXX","XXXXXXX","VT","FF","CR","SO","SI",
23 "DLE","DC1","DC2","DC3","XXXXXXX","XXXXXXX","BS","XXXXXXX","CAN","EM","XXXXXXX","XXXXXXX","IFS","IGS","IRS","IUS ITB",
24 "XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","LF","ETB","ESC","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","ENQ","ACK","BEL",
25 "XXXXXXX","XXXXXXX","SYN","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","EOT","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","DC4","NAK","XXXXXXX","SUB",
26 "SP","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",".","<","(","+","|",
27 "&","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","!","$","*",")",";","XXXXXXX",
28 "-","/","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",",","%","_",">","?",
29 "XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","`",":","#","@","\'","=","\"",
30 "XXXXXXX","a","b","c","d","e","f","g","h","i","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",
31 "XXXXXXX","j","k","l","m","n","o","p","q","r","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",
32 "XXXXXXX","~","s","t","u","v","w","x","y","z","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",
33 "^","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","[","]","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",
34 "{","A","B","C","D","E","F","G","H","I","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",
35 "}","J","K","L","M","N","O","P","Q","R","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",
36 "\\","XXXXXXX","S","T","U","V","W","X","Y","Z","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX",
37 "0","1","2","3","4","5","6","7","8","9","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX","XXXXXXX"
38 };
39 string str2[]=
40 {
41     "NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","HT","LF","VT","FF","CR","SO","SI",
42 "DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM","SUB","ESC","IFS","IGS","IRS","IUS ITB",
43 "SP","!","\"","#","$","%","&","\'","(",")","*","+",",","-",".","/",
44 "0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?",
45 "@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O",
46 "P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_",
47 "`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
48 "p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","DEL"
49 };
50 char s[10000000];
51 int change(char ch)
52 {
53     if(ch <='9')return ch-'0';
54     else return ch-'A'+10;
55 }
56 int main()
57 {
58     //freopen("in.txt","r",stdin);
59     //freopen("out.txt","w",stdout);
60     while(scanf("%s",s)==1)
61     {
62         int n = strlen(s);
63         for(int i = 0;i < n;i+=2)
64         {
65             int p = change(s[i])*16 + change(s[i+1]);
66             int t = 0;
67             while(t < 128 && str2[t] != str[p])t++;
68             printf("%02X",t);
69         }
70         printf("\n");
71     }
72     return 0;
73 }

 

 

 

 

 

 

    原文作者:算法小白
    原文地址: https://www.cnblogs.com/kuangbin/p/3270834.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞