1. (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.
  2. (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.
    TETRIS
  3. (30%) Modify your "Running Q" homework and change it to a "Running Horse" program.
    1. Use the string "^/-\~" to represent a horse.
    2. Horses run towards the left.
    3. 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.

    Colored Horse
  4. (30%) Consider a tranposition cipher called "Scytale" which was popularly adopted by the ancient Greeks and Spartans.
    1. 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).
    2. Then he starts writing his message along the length of the stick, one character per pass of the paper.
    3. 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".
    4. To decrypt it, the receiver wraps the strip along a stick with the same diameter, and read the message along the rows.
    5. 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.
    6. You may test your program with a message "ABCDEABCDEABCDEABCDEABCDE". For key = 5, it should be decrypted as "AAAAABBBBBCCCCCDDDDDEEEEE".
  5. (30%) Write a program to calculate the number of prime numbers less than 1,005,000. Submit the number and your C++ program.