This is a partial judge problem.
You're asked to implement several Codecs that inherit the Codec.
class Codec {
public:
virtual void encode() = 0;
virtual ~Codec() { } // Do nothing
virtual void show() = 0;
};
There are three types of Codecs.
The first one is Number Codec, which maps the letters to numbers, where the letters a ~ z correspond to 1 ~ 26, respectively.
For example:
the text: helloworld
the text after encoding: 85121215231518124
The second one is Two digits Number Codec, which maps the letters to numbers, where the letters a ~ z correspond to 1 ~ 26, respectively, and if the number is smaller than 10, add a 0 in front.
For example:
the text: helloworld
the text after encoding: 08051212152315181204
The third one is The Rail-Fence Cipher Codec, which divides the text into two lines, and then combines them into a sentence in the order up and down. If the length of the text is odd, the upper length is (n+1)/2 and the lower length is (n-1)/2.
For example:
the text: HelloWorld!
divide the text into two lines:
H e l l o W
o r l d !
the text after encoding: Hoerllldo!W
In this problem, you only need to implement three functions in your 'function.cpp':
#include<iostream>
#include<string>
#include "function.h"
using namespace std;
void Number_Codec::encode()
{
// your code here
}
void Two_Number_Codec::encode()
{
// your code here
}
void The_Rail_Fence_Cipher_Codec::encode()
{
// your code here
}
The input contains only one line, the text and the type of the Codec.
Test cases:
(3/10) 0 < | text | <= 100, Codec = Number
(3/10) 0 < | text | <= 100, Codec = Two_Number
(4/10) 0 < | text | <= 100, Codec = The_Rail_Fence_Cipher
Output the text after encoding.