Write a matching pair of SAL programs named "encode" and "decode",
which implement a simple secret code. "encode" reads a string of
characters and keeps track of how many there are. (You may assume there
are at most 60 characters.) If there are not an exact multiple of 3,
it adds a space or two at the end so there are an exact multiple of 3.
It then stores them into a 3-row, 20-column array of characters, going
down the first column, then down the second column, etc. Once this is
done, it reads off the bottom row from left to right, then the middle row
from left to right, then the top row from left to right, printing out
the characters as it goes. For example, the string
This is a test of my encoding program.
is 38 characters long, so the program would add a space at the end and
build the table
T
| s
| s
|
| s
| o
| m
| e
| o
| n
| p
| g
| m
|
h
|
|
| t
| t
| f
| y
| n
| d
| g
| r
| r
| .
|
i
| i
| a
| e
|
|
|
| c
| i
|
| o
| a
|
|
The encoded result would then be the string
iiae ci oa h ttfyndgrr.Tss someonpgm
The "decode" program, naturally enough, will do the opposite: if you
type in
iiae ci oa h ttfyndgrr.Tss someonpgm
it will print out
This is a test of my encoding program.
Hint: You may want to write this program in Pascal or C
first, to make sure you've got the algorithm right.