unit Unit5; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type Tfirst = '1' .. '8'; Tsecond = '1' .. '8'; const TPolibius: array[Tfirst, Tsecond] of char = ( ('_', 'А', 'Б', 'В', 'Г','Д', 'Е', 'Ё'), ('Ж', 'З', 'И','Й','К', 'Л','М', 'Н'), ('О','П', 'Р', 'С', 'Т', 'У','Ф', 'Х'), ('Ц','Ч', 'Ш', 'Щ','Ъ', 'Ы','Ь','Э'), ('Ю', 'Я', '0', '1','2', '3', '4','5'), ('6', '7', '8', '9', '(',')', '[', ']'), ('{', '}', '.', ',', ':',';', '?', '!'), ('-', '"', '+', '=', '№','%', '*', '/') ); function PolibiusEncipher(toCode: string): string; var i: integer; ix: Tfirst; jx: Tsecond; s: string; begin s := ''; for i := 1 to length(toCode) do begin for ix := Low(Tfirst) to High(Tfirst) do for jx := Low(Tsecond) to High(Tsecond) do if TPolibius[ix, jx] = toCode[ i ] then begin s := s + ix + jx; break; end; end; PolibiusEncipher := s end; function PolibiusDecipher(toDecode: string): string; var i: integer; s: string; begin s := ''; i := 1; while i <= length(toDecode) do begin s := s + TPolibius[toDecode[ i ], toDecode[succ(i)]]; inc(i, 2); end; PolibiusDecipher := s end; procedure TForm1.Button1Click(Sender: TObject); begin s := PolibiusEncipher('POLIBIUS'); // writeln(s); Memo1.lines.add(s); Memo1.lines.add('s = '+ PolibiusDecipher(s)); end; end.