См. перевод десятичного числа в двоичную и восьмеричную системы счисления, перевод десятичного числа в шестнадцатеричное число.
var decimal: integer; binary, octal, hexa: string; function binary_octal(bin_oct:byte;decimal:integer): string; begin binary_octal := ''; while decimal > 0 do begin binary_octal := chr(ord('0') + (decimal mod bin_oct)) + binary_octal; decimal := decimal div bin_oct end; end; function hexadecimal(decimal:integer):string; var digit:byte; ch:char; begin hexadecimal := ''; while decimal > 0 do begin digit := decimal mod 16; if digit in [10..15] then case digit of 10: ch := 'A'; 11: ch := 'B'; 12: ch := 'C'; 13: ch := 'D'; 14: ch := 'E'; 15: ch := 'F' end else ch := chr(ord('0') + digit); hexadecimal := ch + hexadecimal; decimal := decimal div 16 end; end; begin write('Decimal: '); readln(decimal); binary := binary_octal(2,decimal); octal := binary_octal(8,decimal); hexa := hexadecimal(decimal); writeln('notation:':10,'2':10,'8':5,'10':5,'16':5); writeln('value:':10,binary:10,octal:5,decimal:5,hexa:5); readln end.
Последние комментарии
3 дня 2 часа назад
3 дня 9 часов назад
3 дня 15 часов назад
4 дня 22 часа назад
1 неделя 17 часов назад
1 неделя 19 часов назад
1 неделя 1 день назад
1 неделя 2 дня назад
1 неделя 2 дня назад
1 неделя 3 дня назад