We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent de4b21d commit 611cd7bCopy full SHA for 611cd7b
progs/ccipher.psc
@@ -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
17
+ cipher <- cipher + CODE_TO_CHAR(code)
18
+ENDFOR
19
+OUTPUT 'Cipher: ' + cipher
0 commit comments