-->
当前位置:首页 > 题库

PROGRAMMING:Caesar encryption (back offset)

Luz5年前 (2021-05-10)题库485
In order to prevent the information from being stolen easily, it is necessary to transform the plaintext into ciphertext by means of encryption. Enter a character string with carriage return as the end mark (less than 80 characters), and then enter a positive integer offset, which is encrypted with Caesar password and output. Caesar cipher is a simple replacement encryption technology, all the letters in the plaintext are shifted back offset bit on the alphabet and replaced with ciphertext.
For example, when offset is 2, it means that all the letters are replaced by the letters that are moved 2 bits backward, that is, all the letters a will be replaced by C, B will become D,..., x will become Z, y will become a, Z will become B.
###Input format:
Input the first line to give a non empty string (less than 80 characters) ending with carriage return; On the second line, enter a positive integer offset.
###Output format:
Output the encrypted result string.
If the input offset is not in the valid range, output "invalid." in one line.
###Input sample 1:
Here is a set of inputs. For example:
```in
Hello Hangzhou
two
```
###Output sample 1:
The corresponding output is given here. For example:
```out
Jgnnq Jcpibjqw
```
###Input sample 2:
Here is a set of inputs. For example:
```in
z=x+y
-1
```
###Output sample 2:
```out
Invalid.
```






answer:If there is no answer, please comment