#K8366. Caesar Cipher Encryption and Decryption
Caesar Cipher Encryption and Decryption
Caesar Cipher Encryption and Decryption
This problem requires you to implement two functions: one to encrypt and another to decrypt a given lowercase string using the Caesar cipher.
In the encryption process, each character in the string is shifted forward by k positions in the alphabet. Conversely, in the decryption process, each character is shifted backward by k positions. The transformation for a given character c is given by the formula:
$$ c' = ((c - 'a' + k) \mod 26) + 'a' $$
where c' is the encrypted character. The decryption process subtracts the shift k instead of adding it.
The program should read input from standard input and output the result to standard output.
inputFormat
The input consists of three lines:
- The first line contains a single character representing the operation: 'E' for encryption or 'D' for decryption.
- The second line contains an integer k (0 ≤ k ≤ 109) representing the number of positions by which the characters should be shifted.
- The third line contains a string s consisting only of lowercase English letters.
outputFormat
Output the resulting string after performing the encryption or decryption as specified by the input. The output should be written to standard output.
## sampleE
3
hello
khoor