Run-Length Encoding(RLE) is implemented as class "RleCodec".
More about RLE :
The rule of run-length encoding is simple: Count the number of consecutive repeated characters in a string, and replace the repeated characters by the count and a single instance of the character. For example, if the input string is ‘AAADDDDDDDBBGGGGGCEEEE’, its run-length encoding will be ‘3A7DBB5GC4E’, because there are three A’s, seven D’s, … etc.
Note that we do not need to encode runs of length one or two, since ‘2B’ and ‘1C’ are not shorter than ‘BB’ and ‘C’.
As we have practiced RLE before, the functions you need to compete are "RleCodec::encode" and "RleCodec::decode".
Functions "show" , " is_encoded " are already done for you.
You may take the class "DummyCodec" as a sample of implementing a derived class of the base class "Codec". You should not change anything in "function.h".
Hint: std::stringstream could be useful in solving this problem. For more details, you may see cheatsheet.
Note :
1. You only need to submit ‘function.cpp’, since it's a partial judge. Partial Code is provided.
2. Note that if you can't use "auto".
a.) For codeblock, go to the codeblock menu Settings --> Compiler ... --> Compiler flags and check
Have g++ follow the C++11 ISO C++ language standard [-std=c++11]
b.) For command line compiler, use g++ myprog.cpp -std=c++11 -o myprog
3. For OJ submission, you may choose c++ 11 as your compiler.
You may include these library in function.cpp
A line contains of several characters .
There are four lines.
The first and second lines are dummy encoding and decoding. You don't need to implement it.
The third and forth lines are RLE encoding and decoding.
Each line is followed by a new line character.