bab_mail

question/172931838

Dec 8th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.44 KB | None | 0 0
  1. program q172933272;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7.  
  8. function Hex2BinDigit(aValue: char): string;
  9. begin
  10.   case aValue of
  11.     '0': Result := '0000';
  12.     '1': Result := '0001';
  13.     '2': Result := '0010';
  14.     '3': Result := '0011';
  15.     '4': Result := '0100';
  16.     '5': Result := '0101';
  17.     '6': Result := '0110';
  18.     '7': Result := '0111';
  19.     '8': Result := '1000';
  20.     '9': Result := '1001';
  21.     'A': Result := '1010';
  22.     'B': Result := '1011';
  23.     'C': Result := '1100';
  24.     'D': Result := '1101';
  25.     'E': Result := '1110';
  26.     'F': Result := '1111';
  27.   end;
  28. end;
  29.  
  30. function Trim(aValue: string): string;
  31. begin
  32.   while (aValue[1] = '0') do
  33.   begin
  34.     Delete(aValue, 1, 1);
  35.     if (Length(aValue) = 1) then
  36.       break;
  37.   end;
  38.   Result := aValue;
  39. end;
  40.  
  41. function Hex2Bin(aValue: string): string;
  42. var
  43.   i: Cardinal;
  44. begin
  45.   Result := '';
  46.   for i := 1 to Length(aValue) do
  47.     Result := Result + Hex2BinDigit(UpCase(aValue[i]));
  48.   Result := Trim(Result);
  49. end;
  50.  
  51. var
  52.   value: string;
  53. begin
  54.   readln(value);
  55.   //value := '1E0E4E8EE20EEE5EB20F0F22CF220F1FCE4E5EEEDE2FB20E8EC2049202074652ED2E120E0EEE2E1F0F220CAF1EFE4E5E6EE204154E8ECEDECECF2E5205720FBEEEE6B6F436E650D696573654963020A65746567740D054D6D05656F046574AF036F0205697403014869680300466E2E687265074446555443415354466E2E6F6F0763576E6F54780B6F7448696802096F744E6D0654686D0A6F745379650050726E466E0853726C42720773567';
  56.   writeln(Hex2Bin(value));
  57.   readln;
  58. end.
Advertisement
Add Comment
Please, Sign In to add comment