Программа:
var n:integer;s:string;
procedure hex(a:integer; var h:string);
var i,m:integer; s1,s2:string;
begin
s2:='ABCDEF';
h:='';
for i:=1 to 4 do
begin
m:=a mod 16;
case m of
0..9 : str(m,s1);
10..15 : s1:=s2[m-9];
end;
h:=s1+h;
a:=a div 16;
end;
end;
begin
write('n = '); readln(n);
hex(n,s);
writeln(n,'(10) = ',s,'(16)');
end.
Пример:
n = 4095
4095(10) = 0FFF(16)