Const n=26; ab='ABCDEFGHIJKLMNOPQRSTUVWXYZ';
procedure Caesar(s:string;k:integer; var t:string);
var i,p,j:integer;
begin
t:='';
for i:=1 to length(s) do
begin
p:=pos(s[i],ab);
if p>0 then begin
j:=(p+k-1) mod n+1;
if j<=0 then j:=n+j;<br> t:=t+ab[j];
end
else t:=t+s[i];
end;
end;
var t:string;
begin
Caesar('ANZ',3,t);
writeln(t);
Caesar(t,-3,t);
writeln(t);
end.
Пример:
DQC
ANZ