EBCDIC (多校联合赛第九场E题)

E. EBCDIC

Time Limit: 2000ms
Case Time Limit: 2000ms
Memory Limit: 102400KB
64-bit integer IO format:  %I64d      Java class name:  Main
Font Size:  +   -
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



这题很坑爹啊。是个打表题,打了很久,还好 1 A了


#include <iostream>
#include <string>
#include <map>
using namespace std;

map <string,string> mp,mp1;

void ini(){					
mp["00"]="NUL";
mp["01"]="SOH";
mp["02"]="STX";
mp["03"]="ETX";
mp["05"]="HT";
mp["07"]="DEL";
mp["0B"]="VT";
mp["0C"]="FF";
mp["0D"]="CR";
mp["0E"]="SO";
mp["0F"]="SI";
mp["10"]="DLE";
mp["11"]="DC1";
mp["12"]="DC2";
mp["13"]="DC3";
mp["16"]="BS";
mp["18"]="CAN";
mp["19"]="EM";
mp["1C"]="IFS";
mp["1D"]="IGS";
mp["1E"]="IRS";
mp["1F"]="IUSITB";
mp["25"]="LF";
mp["26"]="ETB";
mp["27"]="ESC";
mp["2D"]="ENQ";
mp["2E"]="ACK";
mp["2F"]="BEL";
mp["32"]="SYN";
mp["37"]="EOT";
mp["3C"]="DC4";
mp["3D"]="NAK";
mp["3F"]="SUB";
mp["40"]="SP";
mp["4B"]=".";
mp["4C"]="<";
mp["4D"]="(";
mp["4E"]="+";
mp["4F"]="|";
mp["50"]="&";
mp["5A"]="!";
mp["5B"]="$";
mp["5C"]="*";
mp["5D"]=")";
mp["5E"]=";";
mp["60"]="-";
mp["61"]="/";
mp["6B"]=",";
mp["6C"]="%";
mp["6D"]="_";
mp["6E"]=">";
mp["6F"]="?";
mp["79"]="`";
mp["7A"]=":";
mp["7B"]="#";
mp["7C"]="@";
mp["7D"]="'";
mp["7E"]="=";
mp["7F"]="\"";
mp["81"]="a";
mp["82"]="b";
mp["83"]="c";
mp["84"]="d";
mp["85"]="e";
mp["86"]="f";
mp["87"]="g";
mp["88"]="h";
mp["89"]="i";
mp["91"]="j";
mp["92"]="k";
mp["93"]="l";
mp["94"]="m";
mp["95"]="n";
mp["96"]="o";
mp["97"]="p";
mp["98"]="q";
mp["99"]="r";
mp["A1"]="~";
mp["A2"]="s";
mp["A3"]="t";
mp["A4"]="u";
mp["A5"]="v";
mp["A6"]="w";
mp["A7"]="x";
mp["A8"]="y";
mp["A9"]="z";
mp["B0"]="^";
mp["BA"]="[";
mp["BB"]="]";
mp["C0"]="{";
mp["C1"]="A";
mp["C2"]="B";
mp["C3"]="C";
mp["C4"]="D";
mp["C5"]="E";
mp["C6"]="F";
mp["C7"]="G";
mp["C8"]="H";
mp["C9"]="I";
mp["D0"]="}";
mp["D1"]="J";
mp["D2"]="K";
mp["D3"]="L";
mp["D4"]="M";
mp["D5"]="N";
mp["D6"]="O";
mp["D7"]="P";
mp["D8"]="Q";
mp["D9"]="R";
mp["E0"]="\\";
mp["E2"]="S";
mp["E3"]="T";
mp["E4"]="U";
mp["E5"]="V";
mp["E6"]="W";
mp["E7"]="X";
mp["E8"]="Y";
mp["E9"]="Z";
mp["F0"]="0";
mp["F1"]="1";
mp["F2"]="2";
mp["F3"]="3";
mp["F4"]="4";
mp["F5"]="5";
mp["F6"]="6";
mp["F7"]="7";
mp["F8"]="8";
mp["F9"]="9";
}

void ini2(){
mp1["NUL"]="00";
mp1["SOH"]="01";
mp1["STX"]="02";
mp1["ETX"]="03";
mp1["EOT"]="04";
mp1["ENQ"]="05";
mp1["ACK"]="06";
mp1["BEL"]="07";
mp1["BS"]="08";
mp1["HT"]="09";
mp1["LF"]="0A";
mp1["VT"]="0B";
mp1["FF"]="0C";
mp1["CR"]="0D";
mp1["SO"]="0E";
mp1["SI"]="0F";
mp1["DLE"]="10";
mp1["DC1"]="11";
mp1["DC2"]="12";
mp1["DC3"]="13";
mp1["DC4"]="14";
mp1["NAK"]="15";
mp1["SYN"]="16";
mp1["ETB"]="17";
mp1["CAN"]="18";
mp1["EM"]="19";
mp1["SUB"]="1A";
mp1["ESC"]="1B";
mp1["IFS"]="1C";
mp1["IGS"]="1D";
mp1["IRS"]="1E";
mp1["IUSITB"]="1F";
mp1["SP"]="20";
mp1["!"]="21";
mp1["\""]="22";
mp1["#"]="23";
mp1["$"]="24";
mp1["%"]="25";
mp1["&"]="26";
mp1["'"]="27";
mp1["("]="28";
mp1[")"]="29";
mp1["*"]="2A";
mp1["+"]="2B";
mp1[","]="2C";
mp1["-"]="2D";
mp1["."]="2E";
mp1["/"]="2F";
mp1["0"]="30";
mp1["1"]="31";
mp1["2"]="32";
mp1["3"]="33";
mp1["4"]="34";
mp1["5"]="35";
mp1["6"]="36";
mp1["7"]="37";
mp1["8"]="38";
mp1["9"]="39";
mp1[":"]="3A";
mp1[";"]="3B";
mp1["<"]="3C";
mp1["="]="3D";
mp1[">"]="3E";
mp1["?"]="3F";
mp1["@"]="40";
mp1["A"]="41";
mp1["B"]="42";
mp1["C"]="43";
mp1["D"]="44";
mp1["E"]="45";
mp1["F"]="46";
mp1["G"]="47";
mp1["H"]="48";
mp1["I"]="49";
mp1["J"]="4A";
mp1["K"]="4B";
mp1["L"]="4C";
mp1["M"]="4D";
mp1["N"]="4E";
mp1["O"]="4F";
mp1["P"]="50";
mp1["Q"]="51";
mp1["R"]="52";
mp1["S"]="53";
mp1["T"]="54";
mp1["U"]="55";
mp1["V"]="56";
mp1["W"]="57";
mp1["X"]="58";
mp1["Y"]="59";
mp1["Z"]="5A";
mp1["["]="5B";
mp1["\\"]="5C";
mp1["]"]="5D";
mp1["^"]="5E";
mp1["_"]="5F";
mp1["`"]="60";
mp1["a"]="61";
mp1["b"]="62";
mp1["c"]="63";
mp1["d"]="64";
mp1["e"]="65";
mp1["f"]="66";
mp1["g"]="67";
mp1["h"]="68";
mp1["i"]="69";
mp1["j"]="6A";
mp1["k"]="6B";
mp1["l"]="6C";
mp1["m"]="6D";
mp1["n"]="6E";
mp1["o"]="6F";
mp1["p"]="70";
mp1["q"]="71";
mp1["r"]="72";
mp1["s"]="73";
mp1["t"]="74";
mp1["u"]="75";
mp1["v"]="76";
mp1["w"]="77";
mp1["x"]="78";
mp1["y"]="79";
mp1["z"]="7A";
mp1["{"]="7B";
mp1["|"]="7C";
mp1["}"]="7D";
mp1["~"]="7E";
mp1["DEL"]="7F";

}

int main(){
	ini();
	ini2();
	string st;
	while(cin>>st){
		for(int i=0;i<st.length();i+=2){
			string tmp;
			tmp.push_back(st[i]);
			tmp.push_back(st[i+1]);
			cout<<mp1[mp[tmp]];
		}
		cout<<endl;
	}
	return 0;
}





转载于:https://www.cnblogs.com/toyking/p/3797411.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值