8000 New example: ccipher.psc · cpp-tutor/pseudocode-compiler@611cd7b · GitHub
[go: up one dir, main page]

Skip to content

Commit 611cd7b

Browse files
committed
New example: ccipher.psc
1 parent de4b21d commit 611cd7b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

progs/ccipher.psc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Caesar cipher (ROT13)
2+
3+
OUTPUT 'Please enter a string:'
4+
str <- USERINPUT
5+
IF str = '' THEN
6+
str <- 'Beware of PLOTS!'
7+
ENDIF
8+
cipher <- ''
9+
FOR letter IN str
10+
code <- CHAR_TO_CODE(letter)
11+
IF code >= CHAR_TO_CODE('A') AND code <= CHAR_TO_CODE('Z') THEN
12+
code <- (code - CHAR_TO_CODE('A') + 13) MOD 26 + CHAR_TO_CODE('A')
13+
ENDIF
14+
IF code >= CHAR_TO_CODE('a') AND code <= CHAR_TO_CODE('z') THEN
15+
code <- (code - CHAR_TO_CODE('a') + 13) MOD 26 + CHAR_TO_CODE('a')
16+
ENDIF
17+
cipher <- cipher + CODE_TO_CHAR(code)
18+
ENDFOR
19+
OUTPUT 'Cipher: ' + cipher

0 commit comments

Comments
 (0)
0