Szyfr Cezara

{$X+}
uses Strings;
var

p:Shortint;
s:array[0..255]of Char;

Procedure cezar(s:PChar;p:shortint);
var i,n:longint;
begin

n:=StrLen(s);
p:=(p+26) mod 26;
for i:=0 to n do
if s[i] in ['a'..'z']
then s[i] := chr( (ord(s[i]) + p - ord('a') ) mod 26 + ord('a') ) else
if s[i] in ['A'..'Z']
then s[i] := chr( (ord(s[i]) + p - ord('A') ) mod 26 + ord('A') );

end;
BEGIN

Writeln('Wprowadz przesuniecie');
Readln(p);
Writeln('Wprowadz text');
Readln(s);
cezar(s,p);
Writeln('Po zakodowaniu');
Writeln(s);
cezar(s,-p);
Writeln('Po rozkodowaniu');
Writeln(s);
Writeln('Wcisnij Enter');
Readln;

END.

O ile nie zaznaczono inaczej, treść tej strony objęta jest licencją Creative Commons Attribution-ShareAlike 3.0 License