#C3913. Caesar Cipher
Caesar Cipher
Caesar Cipher
This problem requires you to implement a Caesar cipher algorithm. Given a message, an integer shift, and a direction ('left' or 'right'), you need to shift the letters of the message accordingly. The cipher works as follows: for each alphabetical character, its new position is determined by the formula \( new = (old + shift) \mod 26 \). Non-alphabet characters remain unchanged.
Note: A right shift moves a letter forward in the alphabet, whereas a left shift moves it backward. The shift value may be larger than 26; in such cases, it should be normalized by taking its modulo with 26.
inputFormat
The input is provided via standard input (stdin) and consists of three lines:
- A string representing the message.
- An integer representing the shift amount.
- A string (either 'left' or 'right') indicating the direction of the shift.
outputFormat
Output the encoded message to standard output (stdout).## sample
abc
1
right
bcd