#C10253. Shift String
Shift String
Shift String
You are given a string s
and an integer k
. Your task is to shift each alphabetic character in the string by k
positions in the English alphabet. The shifting should wrap around if it goes past 'z' or 'Z'. Non-alphabet characters should remain unchanged.
For example, shifting a
by 2 yields c
and shifting z
by 3 yields c
. The case of each letter must be preserved.
Your program should read the input from standard input (stdin
) and write the result to standard output (stdout
).
inputFormat
The input consists of two lines:
- The first line contains the string
s
. - The second line contains an integer
k
, representing the number of positions to shift each letter.
outputFormat
Output a single line with the resulting shifted string.
## sampleabc
2
cde