hdu4690 EBCDIC

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4690



                                                 EBCDIC



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

题意:

给你两个表,输入的是对应第一张表的坐标,求对应符合在第二张表格的坐标

坑点注意,不要用cin,cout,有时的偷懒会让你超时的!!!大笑

(码的我也是好辛苦,特地来纪念一发~)


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define LL __int64
#define MOD 1000000007
const int INF = 0x3f3f3f3f;
string A[16][16]= {"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 B[8][16]= {"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"};

//vector<int>q;
int main()
{
    char a,b;
    //string c;
    while(1)
    {
        a=getchar();
        if(a=='\n')break;
        b=getchar();
        int i,j,aa,bb;
        if(a>='A'&& a<='F')aa=a-'A'+10;
        if(a>='0'&& a<='9')aa=a-'0';
        if(b>='A'&& b<='F')bb=b-'A'+10;
        if(b>='0'&& b<='9')bb=b-'0';
        for(i=0; i<8; i++)
        {
            for(j=0; j<16; j++)
                if(B[i][j]==A[aa][bb])
                {
                    a=i+'0';
                    if(j>=0&&j<=9)
                        b=j+'0';
                    else
                        b=j-10+'A';
                    break;
                }
        }
       printf("%c%c",a,b);
    }
    printf("\n");
    return 0;
}






















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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值