#C13108. Shift Characters
Shift Characters
Shift Characters
Given a string s
consisting of lowercase English letters and an integer shift
, generate a new string by shifting every character in s
by shift
positions in the alphabet. The shifting is cyclic; that is, when a character passes 'z', it wraps around back to 'a'.
You can express the transformation of each character \( c \) mathematically as follows:
$$c' = \mathrm{chr}(((\mathrm{ord}(c) - \mathrm{ord}('a') + shift) \bmod 26) + \mathrm{ord}('a'))$$
Write a program that reads the input from stdin, applies the transformation to every character, and prints the resulting string to stdout.
inputFormat
The input consists of two lines:
- The first line contains a string
s
consisting only of lowercase English letters. - The second line contains an integer
shift
indicating the number of positions each character should be shifted.
outputFormat
The output should be a single line containing the transformed string after applying the cyclic shift.
## sampleabc
1
bcd
</p>