Assignment 3: Decoder

Write a program that converts a sequence of bits into messages (this process is known as decoding). There are four types of bit encoding: 0, 10, 110, 111. The corresponding message for each bit encoding is shown below.

Example 1 (click to see the figure):

Enter a sequence of bits: 110010111

Rainy Fine Cloudy Snow

   assert(i >= 0);

   assert(i < code.length());

   cout << code[i] << endl;

   assert(i+1 >= 0);

   assert(i+1 < code.length());

   cout << code[i+1] << endl;