题解 | #字符串加密#

字符串加密

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

letters = 'abcdefghijklmnopqrstuvwxyz'

while True:
    try:
        word, s = input(), input()
        key = ''
        # 去重
        for c in word.lower():
            if c not in key:
                key += c
        # 补全
        for c in letters:
            if c not in key:
                key += c
        # 加密
        code = ''
        for c in s:
            if c.isupper():
                i = letters.index(c.lower())
                code += key[i].upper()
            elif c.islower():
                i = letters.index(c)
                code += key[i]
        print(code)
    except:
        break
全部评论

相关推荐

07-15 12:24
重庆大学 运营
坏消息:和好工作擦肩而过
给点吧求求了:怎么可能因为差几秒,估计就是简历更好看婉拒了
点赞 评论 收藏
分享
机械打工仔:有说的你怀疑一下就行了,直接问也太实诚了
点赞 评论 收藏
分享
评论
3
3
分享

创作者周榜

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