Caesar Cipher Encryption


Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 10M

Author:
Problem type

Description

請撰寫一個程式,輸入一個字串 s 與一個整數 k,並使用 for loop 進行凱薩密碼加密。

凱薩密碼規則:將每個英文字母往後位移 k 個位置。

例如:

  • a 位移 3 範例 abcd
  • x 位移 3 範例 xyza
  • H 位移 5 範例 HIJKLM

Requirements

  1. 輸入

    • 一個字串 s 長度 ≤ 100
    • 一個整數 k 且已知 0 ≤ k ≤ 25
  2. 規則

    • 小寫字母保持小寫、大寫字母保持大寫,且非英文字母保持不變
    • 超過 zZ 時需回到開頭
  3. 輸出

    • 輸出加密後的字串

Input and Output

Sample 1 Sample 2 Sample 3
INPUT abc123
3
xyz
3
Hello
5
OUTPUT def123 abc Mjqqt

Comments

There are no comments at the moment.