题解 | #字符串加密#

字符串加密

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

思路:构造对应字母表,对应位置取值输出即可
key = input()
s = input()
alp1 = 'abcdefghijklmnopqrstuvwxyz' # 构造alp1
alp2 = ''
for i in key + alp1: # 构造alp2(将key和alp1串连,剔除后出现的重复字母)
    if i not in alp2:
        alp2 += i
for i in s:
    print(alp2[alp1.index(i)],end='') # 对应输出(不换行)


全部评论

相关推荐

评论
点赞
2
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务