11449 - Encoding and decoding of Caesar’s Cipher   

Description

Caesar’s cipher is a substitution cipher. Given an integer (shift), each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, given shift = -3, C would be replaced by Z, D would be replaced by A, and so on. 

Example:

encoding for shift = -3

decoding for shift = -3

 

We have the base class ‘Codec’ as an interface. The member functions in ‘Codec’ are pure virtual functions. Therefore we need to implement those virtual functions in the derived class ‘CaesarCodec’. You are asked to implement the functions ‘encode’, ‘decode’ of ‘CaesarCodec’ in ‘function.cpp’.

 

 

 

Input

An uppercase string and a shift

Note:

  1. The shift may be positive or negative.
  2. The absolute value |shift| may be larger than 26.

Output

There are four lines.

The first and second lines are dummy encoding and decoding. You don’t need to implement it.

The third and fourth lines are Caesar encoding and decoding.

Each line is followed by a new line character.

 

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

11449.cpp

Partial Judge Header

11449.h

Tags




Discuss