题解 | #字符串加解密#

字符串加解密

https://www.nowcoder.com/practice/2aa32b378a024755a3f251e75cbf233a

s1 = input()
s2 = input()
res1 = []
res2 = []

for i in s1:
    if i.isupper() and i != 'Z':
        #i = i.lower()
        res1.append(chr(ord(i.lower())+1))
    if i.islower() and i != 'z':
        #i = i.lower()
        res1.append(chr(ord(i.upper())+1))
    if i == 'Z':
        #i = i.lower()
        res1.append("a")
    if i == 'z':
        #i = i.lower()
        res1.append("A")
    if i.isdigit() and i != str(9):
        res1.append(str(int(i)+1))
    if i == str(9):
        res1.append("0")

for i in s2:
    if i.isupper() and i != 'A':
        #i = i.lower()
        res2.append(chr(ord(i.lower())-1))
    if i.islower() and i != 'a':
        #i = i.lower()
        res2.append(chr(ord(i.upper())-1))
    if i == 'a':
        #i = i.lower()
        res2.append("Z")
    if i == 'A':
        #i = i.lower()
        res2.append("z")
    if i.isdigit() and i != str(0):
        res2.append(str(int(i)-1))
    if i == str(0):
        res2.append("9")

print("".join(res1))
print("".join(res2))

全部评论

相关推荐

牛客279957775号:铁暗恋
点赞 评论 收藏
分享
牛客717484937号:双飞硕没实习挺要命的
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务