- (30%) Let a, b, c
, denote different numeric digits (0 .. 9). Design a C++ program
to list all combinations that will look like aa*ac=abba. In this
example, a is a leading digit, so it cannot be zero.
- (30%) Modify your TETRIS homework so that when the user presses the
key '1' ... '7', the program display the colored block corresponding to
the number (as shown in the figure below), instead of showing only a
space.
- (30%) Modify your "Running Q" homework and change it to a "Running
Horse" program.
- Use the string "^/-\~" to represent a horse.
- Horses run towards the left.
- When a horse is close to the finish line (e.g. only 5 steps
away), change the color of the horse to indicate that it is
sprinting.
- (30%) Consider a tranposition
cipher called "Scytale" which was
popularly adopted by the ancient Greeks and Spartans.
- Each general was given a stick of the same diameter.
To encrypt a
message, he wraps a strip of paper (parchment in ancient time)
around the stick (avoid overlapping and gaps).
- Then he starts writing
his
message along the length of the stick, one character per pass of the
paper.
- This is equivalent to have a matrix with a fixed height. The general
writes his message across the rows. When the receiver got the unwrapped
strip, the strip actually shows characters along the columns. For
example,
H | E | L | P | M
|
E | I | A | M | U
|
N | D | E | R | A
|
T | T | A | C | K
|
will be sent as
"HENTEIDTLAEAPMRCMUAK".
- To decrypt it, the receiver wraps the strip along a stick with the same
diameter, and read the message along the rows.
- Nowadays, this task can be quickly done by
computers. Suppose you receive a message "Sestnas hdt feiesl alhosnloao iwtuOt itceonhe bgeaij rnmein.acn Agt IA"
and your know the height of the matrix is 5,
write a program to decrypt it.
- You may test your program with a message
"ABCDEABCDEABCDEABCDEABCDE". For key = 5, it should be decrypted as
"AAAAABBBBBCCCCCDDDDDEEEEE".
- (30%) Write a program to calculate the number of prime numbers less
than 1,005,000. Submit the number and your C++ program.