UVA-865 - Substitution Cypher
19 Apr 2018
- UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt。
- 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
- 本題選為「20161220 大學程式能力檢定 CPE」題目。
題意概要
字母替換可說是一種最簡單的加密方式,本題給定字母的替換方式,請對明文做加密。
- 分析:本題為簡單的資料結構實作,題目會給定一組原始的字母和一組對應替換的字母,建議使用
#include <map>
將儲存好的兩組字元陣列對應存入。本題要注意在字串的處理,以及換行符號的問題。
Input
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
- a line containing the plaintext alphabet
- a line containing the substitution alphabet
- several lines of text
Output
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
- a line containing the substitution alphabet
- a line containing the plaintext alphabet
- the converted lines of text
Please note: All lines will be at most characters, plus a trailing end-of-line character. Pass through all characters not found in the plaintext alphabet.
Sample Input
1
abcdefghijklmnopqrstuvwxyz
zyxwvutsrqponmlkjihgfedcba
Shar's Birthday:
The birthday is October 6th, but the party will be Saturday,
October 5. It's my 24th birthday and the first one in some
years for which I've been employed. Plus, I have new clothes.
So I have cause to celebrate. More importantly, though,
we've cleaned the house! The address is 506-D Albert Street.
Extra enticement for CS geeks: there are several systems in
the house, and the party is conveniently scheduled for 3 hours
after the second CSC programming contest ends (not to mention,
within easy walking distance)!
Sample Output
zyxwvutsrqponmlkjihgfedcba
abcdefghijklmnopqrstuvwxyz
Sszi'h Brigswzb:
Tsv yrigswzb rh Oxglyvi 6gs, yfg gsv kzigb droo yv Szgfiwzb,
Oxglyvi 5. Ig'h nb 24gs yrigswzb zmw gsv urihg lmv rm hlnv
bvzih uli dsrxs I'ev yvvm vnkolbvw. Pofh, I szev mvd xolgsvh.
Sl I szev xzfhv gl xvovyizgv. Mliv rnkligzmgob, gslfts,
dv'ev xovzmvw gsv slfhv! Tsv zwwivhh rh 506-D Aoyvig Sgivvg.
Ecgiz vmgrxvnvmg uli CS tvvph: gsviv ziv hvevizo hbhgvnh rm
gsv slfhv, zmw gsv kzigb rh xlmevmrvmgob hxsvwfovw uli 3 slfih
zugvi gsv hvxlmw CSC kiltiznnrmt xlmgvhg vmwh (mlg gl nvmgrlm,
drgsrm vzhb dzoprmt wrhgzmxv)!