Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Caesar-cipher/Seed7/caesar-cipher.seed7
Normal file
29
Task/Caesar-cipher/Seed7/caesar-cipher.seed7
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const func string: rot (in string: stri, in integer: encodingKey) is func
|
||||
result
|
||||
var string: encodedStri is "";
|
||||
local
|
||||
var char: ch is ' ';
|
||||
var integer: index is 0;
|
||||
begin
|
||||
encodedStri := stri;
|
||||
for ch key index range stri do
|
||||
if ch >= 'a' and ch <= 'z' then
|
||||
ch := chr((ord(ch) - ord('a') + encodingKey) rem 26 + ord('a'));
|
||||
elsif ch >= 'A' and ch <= 'Z' then
|
||||
ch := chr((ord(ch) - ord('A') + encodingKey) rem 26 + ord('A'));
|
||||
end if;
|
||||
encodedStri @:= [index] ch;
|
||||
end for;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
const integer: exampleKey is 3;
|
||||
const string: testText is "The five boxing wizards jump quickly";
|
||||
begin
|
||||
writeln("Original: " <& testText);
|
||||
writeln("Encrypted: " <& rot(testText, exampleKey));
|
||||
writeln("Decrypted: " <& rot(rot(testText, exampleKey), 26 - exampleKey));
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue