Python 代码实现:
while True:
try:
key = input().upper()
string = input()
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
encrypted_map = []
res = ''
for i in range(len(key)):
if key[i] not in encrypted_map:
encrypted_map.append(key[i])
for j in alpha:
if j not in encrypted_map:
encrypted_map.append(j)
for k in string:
if k.islower():
res += encrypted_map[alpha.index(k.upper())].lower()
else:
res += encrypted_map[alpha.index(k.upper())]
print(res)
except:
break