Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Secret Messages! X and Y are best friends and they love to chat with each other. But their recent concerns about the privacy of their

Secret Messages!

X and Y are best friends and they love to chat with each other. But their recent concerns about the privacy of their messages has distant them. So they decided to encrypt their messages with a key, K, such that the character of their messages are now shifted K times towards right of their initial value. Their techniques only convert numbers and alphabets while leaving special characters as it is.

Provided the value K you are required to encrypt the messages using their idea of encryption.

INPUT FORMAT

The first line of the input contains, T, the number of messages. The next line contains N, and K, no of characters in the message and key for encryption. The next line contains the message.

OUTPUT FORMAT

Output the encrypted messages on a new line for all the test cases.

CONSTRAINS

1T100

1N106

0K106

SAMPLE INPUT

2

12 4

Hello-World!

16 50

Aarambh@1800-hrs

SAMPLE OUTPUT

Lipps-Asvph!

Yypykzf@1800-fpq

Explanation

For the first test case, the message is "Hello-World!". Shifting "H" towards right by 4 we get "L", similarly sifting "ello" by 4 each we would get "ipps". Now since "-" is a special character we do not need to encrypt this character. After that we have "W" shifting "W" by 4 we come at "A", simlilarly shifting "orld" by 4 each we get "svph" and the last character is again a special character "!" so we do not encrypt this character.

For the second test case, we have "Aarambh@1800-hrs" we shift "A" by 50 which brings us to "Y" after 1 full circular rotation, the next character of the message is "a" which will be encrypted to "y", similarly "rambh" is encrypted in the same manner giving us "pykz". The next character is a special character "@", after that we have "1", shifting "1" by 50 we get "1" itself and similarly encrypting "800" gives us "800". The next character is again a special character "-", after which we have "hrs" which on encrypting will give is "fpq".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions