题解 | #简单密码#

简单密码

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-07 13:31
怀化学院 Java
勇敢牛牛不怕难:又疯一个
点赞 评论 收藏
分享
vegetable_more_exercise:1-1.5万,没错啊,最少是1人民币,在区间内
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务