#C9137. Shift Cipher Encryption
Shift Cipher Encryption
Shift Cipher Encryption
You are given a message consisting of lowercase English letters, digits, and spaces. Your task is to encrypt the message by shifting each letter and digit by a given integer. The shifting is cyclic: letters wrap from 'z' to 'a' and digits wrap from '9' to '0'.
For a letter, the transformation is given by:
\( new\_char = (char - 'a' + shift) \mod 26 + 'a' \)
For a digit, the transformation is:
\( new\_digit = (digit - '0' + shift) \mod 10 + '0' \)
Other characters (such as spaces) should remain unchanged.
Read the entire message and the shift integer from standard input and output the encrypted message to standard output.
inputFormat
The input consists of two lines:
- The first line contains the message string.
- The second line contains a non-negative integer, representing the shift amount.
outputFormat
Output a single line containing the encrypted message.
## samplehello world 123
3
khoor zruog 456