题解 | #字符串加解密#
字符串加解密
https://www.nowcoder.com/practice/2aa32b378a024755a3f251e75cbf233a
s1 = input() s2 = input() upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' lower = 'abcdefghijklmnopqrstuvwxyz' # 加密 s1_y = "" for i in s1: if i in upper: if i == 'Z': s1_y += 'a' else: index2 = upper.index(i)+1 s1_y += lower[index2] elif i in lower: if i == 'z': s1_y += 'A' else: index1 = lower.index(i)+1 s1_y += upper[index1] else: if i == '9': s1_y += '0' else: s1_y += str(int(i)+1) #解密 s2_y = "" for i in s2: if i in upper: if i == 'A': s2_y += 'z' else: index2 = upper.index(i)-1 s2_y += lower[index2] elif i in lower: if i == 'a': s2_y += 'Z' else: index1 = lower.index(i)-1 s2_y += upper[index1] else: if i == '0': s2_y += '9' else: s2_y += str(int(i)-1) print(s1_y) print(s2_y)