题解 | #字符串加密#
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3?tpId=37&tqId=21259&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D3%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=3&judgeStatus=undefined&tags=&title=
key = input()
s = input()
d = dict()
i = 0
for ch in key:
if ch not in d.values():
d[chr(ord('a') + i)] = ch
i += 1
# 将新建立的字母表中未出现的字母按照正常字母表顺序加入新字母表
j = 0
while i < 26:
while chr(ord('a') + j) in d.values():
j += 1
d[chr(ord('a') + i)] = chr(ord('a') + j)
i += 1
for ch in s:
print(d[ch], end='')

查看1道真题和解析
传音控股晋升空间 52人发布