RosettaCodeData/Task/Rot-13/Pascal/rot-13.pascal

36 lines
731 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
program rot13;
2013-04-10 23:57:08 -07:00
var
2019-09-12 10:33:56 -07:00
line: string;
2013-04-10 23:57:08 -07:00
2019-09-12 10:33:56 -07:00
function rot13(someText: string): string;
2013-04-10 23:57:08 -07:00
2019-09-12 10:33:56 -07:00
var
i: integer;
ch: char;
result: string;
begin
result := '';
for i := 1 to Length(someText) do
begin
ch := someText[i];
case ch of
'A' .. 'M', 'a' .. 'm':
ch := chr(ord(ch)+13);
'N' .. 'Z', 'n' .. 'z':
ch := chr(ord(ch)-13);
end;
result := result + ch;
end;
rot13 := result;
end;
2013-04-10 23:57:08 -07:00
begin
2019-09-12 10:33:56 -07:00
while not eof(input) do
begin
readln(line);
writeln(rot13(line));
end;
2013-04-10 23:57:08 -07:00
end.