var n4 := ReadString('a_4 = '); if n4.Length mod 2 = 1 then n4 := '0' + n4;
var n16 := ''; for var i := 0 to n4.Length div 2 - 1 do if Replace4to16.ContainsKey(n4.Substring(2 * i, 2)) then n16 += Replace4to16[n4.Substring(2 * i, 2)] else writeln('Неверные знаки "', n4.Substring(2 * i, 2), '" в числе');
Answers & Comments
Verified answer
//PascalABC.Net 3.1 сборка 1200uses System;
begin
var Replace4to16 := new Dictionary<string, string>();
Replace4to16.Add('00', '0');
Replace4to16.Add('01', '1');
Replace4to16.Add('02', '2');
Replace4to16.Add('03', '3');
Replace4to16.Add('10', '4');
Replace4to16.Add('11', '5');
Replace4to16.Add('12', '6');
Replace4to16.Add('13', '7');
Replace4to16.Add('20', '8');
Replace4to16.Add('21', '9');
Replace4to16.Add('22', 'a');
Replace4to16.Add('23', 'b');
Replace4to16.Add('30', 'c');
Replace4to16.Add('31', 'd');
Replace4to16.Add('32', 'e');
Replace4to16.Add('33', 'f');
var n4 := ReadString('a_4 = ');
if n4.Length mod 2 = 1 then n4 := '0' + n4;
var n16 := '';
for var i := 0 to n4.Length div 2 - 1 do
if Replace4to16.ContainsKey(n4.Substring(2 * i, 2)) then
n16 += Replace4to16[n4.Substring(2 * i, 2)]
else writeln('Неверные знаки "', n4.Substring(2 * i, 2), '" в числе');
writeln(n16);
end.