机器指令
Time Limit:1000MS Memory Limit:65536K
Total Submit:150 Accepted:46
Description
Description
“让我看看…下一个语句是$C64410…翻译成二进制代码是110001100100010000010000…分段后是110-00-110-1100100010000010000…第一段的110对应的汇编指令是mov…接下来的00表示的是寄存器ax…第三段的110表示的是间接寻址…然后1100100010000010000是内存地址…Finallyyyyyy…对应的汇编语句是mov([1044],ax)--将内存地址为1044的内存中的数据存入ax.”
丁丁同学正为下午的Understanding The Machine 作业中一道将十六进制机器码翻译成汇编语言的题忙得焦头烂额。这种对着一个译码表“进行符号转化”的活,向来是丁丁同学最不能容忍的 – 宝贵的时间就在这样的一道”民工题”上一秒一秒地流逝…唉…
丁丁希望你能编写一个程序来帮帮他。当然,他不会那么残忍地让你去编写一个编译器完成整套工作。他只希望你帮他完成一个小小的模块--将十六进制数转化为二进制数。你可以帮助他么?
Input
Input
多组输入,样例数最大为100。
每组输入是一个由"0123456789ABCDEF"十六种字符组成的一个序列。序列的长度N的满足: 0 <= N <= 10,000。每个序列以换行符结束。
Output
Output
这个序列对应的二进制数。输出每个序列后换行。
Sample Input
Sample Input
C6
88D7
Sample Output
Sample Output
11000110
1000100011010111
Source
ahstu@ICPC01
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AK1012 {
class Program {
static void Main(string[] args) {
string s;
string[] str = { "0000" , "0001" , "0010" , "0011" , "0100" , "0101" , "0110" , "0111" , "1000" , "1001" , "1010" , "1011" , "1100" , "1101" , "1110" , "1111" };
while ((s = Console.ReadLine()) != null) {
for (int i = 0 ; i < s.Length ; i++) {
if (s[i] >= '0' && s[i] <= '9')
Console.Write(str[s[i] - '0']);
else
Console.Write(str[s[i] - 'A' + 10]);
}
Console.WriteLine();
}
}
}
}
//long n = Convert.ToInt64(s , 16);
//string ans = Convert.ToString(n , 2);
//Console.WriteLine(ans);