题解 | #字符串加密#

字符串加密

https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3

s1 = 'abcdefghijklmnopqrstuvwxyz'

#去重

n1 = input().strip()
tmp = ''
for i in n1:
    if i not in tmp:
        tmp +=i
n1 = tmp

s2 = n1
#遍历一遍s,对比n1,得到密码信息
for i in s1:
    if i not in n1:
        s2 += i

dic = {}
for i in range(len(s1)):
    dic[s1[i]] = s2[i]


re = []
n2 = input().strip()
for i in n2:
    re.append(dic[i])

print(''.join(re))

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务