#C12131. Shift String Characters
Shift String Characters
Shift String Characters
Given a string and an optional integer shift value (default is 3), transform the string by shifting each alphabetical character by shift positions in the alphabet. The shifting is done cyclically, i.e., after \(z\) comes \(a\) and after \(Z\) comes \(A\). Non-alphabetical characters remain unchanged.
For instance, when the input string is abc
and the shift is 3, the resulting string is def
. Similarly, XYZ
becomes ABC
.
Your program should read from standard input and output the result to standard output.
inputFormat
The input consists of two lines:
- The first line is a string that needs to be shifted. This string may contain spaces and punctuation.
- The second line is an integer representing the shift value. If this line is missing or empty, assume a default shift value of 3.
outputFormat
Output the transformed string after shifting each alphabetical character by the given shift value.## sample
abc
3
def