题解 | #简单密码#

简单密码

https://www.nowcoder.com/practice/7960b5038a2142a18e27e4c733855dac

str_ = input()
l = list(str_)
lr = []
for i in l:  
    if i == '1':
        lr.append(i)
    elif i == '0':
        lr.append(i)
    elif i in ('a','b','c'):
        i = '2'
        lr.append(i)
    elif i in ('d','e','f'):
        i = '3'
        lr.append(i)
    elif i in ('j','k','l'):
        i = '5'
        lr.append(i)
    elif i in ('g','h','i'):
        i = '4'
        lr.append(i)
    elif i in ('m','n','o'):
        i = '6'
        lr.append(i)
    elif i in ('p','q','r','s'):
        i = '7'
        lr.append(i)
    elif i in ('t','u','v'):
        i = '8'
        lr.append(i)
    elif i in ('w','x','y','z'):
        i = '9'
        lr.append(i)
    elif i.isupper():
        if 65 <= ord(i) <= 90:
            if ord(i) == 90:
                i = 'a'
                lr.append(i)
            else:
                i = chr(ord(i) + 1).lower()
                lr.append(i)
    else:
        lr.append(i)
    


print(''.join(map(str,lr)))

根据题目算法做判断分支,处理ASCII序数时候字母是从65-90,过90回到a

全部评论

相关推荐

11-18 15:57
门头沟学院 Java
最终归宿是测开:这个重邮的大佬在重邮很有名的,他就喜欢打92的脸,越有人质疑他,他越觉得爽😂
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务