Hdoj 4690 ebcdic Simulation

Source: Internet
Author: User


Use orc to convert an image into text, and use Vim to record a macro, which can be easily formatted by letters .....

Ebcdic Time Limit: 2000/2000 MS (Java/others) memory limit: 102400/102400 K (Java/Others)
Total submission (s): 811 accepted submission (s): 368


Problem descriptiona mad scientist found an existing ent 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.

 
Inputthe 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 '.
Outputconvert the input from ebcdic to ASCII, and output it in the same format as the input.
Sample Input
C59340D7A2A840C3969587999696
 
Sample output
456c2050742520436f6e67726f6fHintE.html download facilitate text copy http://pan.baidu.com/share/link in the diagram? Consumer id = 453447595 & UK = 352484775
 
Authorzejun Wu (watashi)
Source2013 multi-university training contest 9


#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <map>using namespace std;map<string,int> mp;string EBCDIC[10000]={"NUL","SOH","STX","ETX","  ","HT","  ","DEL","  ","  ","  ","VT","FF","CR","SO","SI","DLE","DC1","DC2","DC3","  ","  ","BS","  ","CAN","EM","  ","  ","IFS","IGS","IRS","IUS ITB","  ","  ","  ","  ","  ","LF","ETB","ESC","  ","  ","  ","  ","  ","ENQ","ACK","BEL","  ","  ","SYN","  ","  ","  ","  ","EOT","  ","  ","  ","  ","DC4","NAK","  ","SUB","SP","  ","  ","  ","  ","  ","  ","  ","  ","  ","  ",".","<","(","+","|","&","  ","  ","  ","  ","  ","  ","  ","  ","  ","!","$","*",")",";","  ","-","/","  ","  ","  ","  ","  ","  ","  ","  ","  ",",","%","_",">","?","  ","  ","  ","  ","  ","  ","  ","  ","  ","`",":","#","@","'","=","\"","  ","a","b","c","d","e","f","g","h","i","  ","  ","  ","  ","  ","  ","  ","j","k","l","m","n","o","p","q","r","  ","  ","  ","  ","  ","  ","  ","~","s","t","u","v","w","x","y","z","  ","  ","  ","  ","  ","  ","^","  ","  ","  ","  ","  ","  ","  ","  ","  ","[","]","  ","  ","  ","  ","{","A","B","C","D","E","F","G","H","I","  ","  ","  ","  ","  ","  ","}","J","K","L","M","N","O","P","Q","R","  ","  ","  ","  ","  ","  ","\\","  ","S","T","U","V","W","X","Y","Z","  ","  ","  ","  ","  ","  ","0","1","2","3","4","5","6","7","8","9","  ","  ","  ","  ","  ","  "};string ASC[10000]={"NUL","SOH","STX","ETX","EOT","ENQ","ACK","BEL","BS","HT","LF","VT","FF","CR","SO","SI","DLE","DC1","DC2","DC3","DC4","NAK","SYN","ETB","CAN","EM","SUB","ESC","IFS","IGS","IRS","IUS ITB","SP","!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","DEL"};void init(){    for(int i=0;i<8;i++)    {        for(int j=0;j<16;j++)        {            mp[ASC[i*16+j]]=i*16+j;        }    }}int num(char c){    if(c>='0'&&c<='9')        return c-'0';    return c-'A'+10;}char CHAR(int x){    if(x<=9) return x+'0';    return x-10+'A';}int main(){    string READ;    init();    while(cin>>READ)    {        for(int i=0,sz=READ.size();i<sz;i+=2)        {            int c1=num(READ[i]),c2=num(READ[i+1]);            string ck=EBCDIC[c1*16+c2];            int id=mp[ck];            printf("%c%c",CHAR(id/16),CHAR(id%16));        }        putchar(10);    }    return 0;}



Hdoj 4690 ebcdic Simulation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.