#将一个十六进制数转换为四位二进制数 def fun1(x1): str1 ='1 2 3 4 5 6 7 8 9' if str(x1) in str1: x = int(x1) elif x1 == 'a' or x1 == 'A': x = 10 elif x1 == 'b' or x1 == 'B': x = 11 elif x1 == 'c' or x1 == 'C': x = 12 elif x1 == 'd' or x1 == 'D': x = 13 elif x1 == 'e' or x1 == 'E': x = 14 elif x1 == 'f' or x1 == 'F': x = 15 temp = [0,0,0,0] n = 0 while x // 2 >= 0 and x != 0: temp[-1-n] = x % 2 x = x // 2 n = n + 1 return temp #将一个四位二进制数转化为十六进制数 def fun2(temp): str1 ='1 2 3 4 5 6 7 8 9' x = int(temp[0])*2**3 + int(temp[1])*2**2 + int(temp[2])*2**1 + int(temp[3])*2**0 num = x if str(x) in str1: num = x elif x == 10: num = 'A' elif x == 11: num = 'B' elif x == 12: num = 'C' elif x == 13: num = 'D' elif x == 14: num = 'E' elif x == 15: num = 'F' return num while True: try: #获取一行输入数据 data = input() #获取输入的两个字符串 str1 = data.split(' ')[0] str2 = data.split(' ')[1] #将两个字符串合并 str3 = str1 + str2 #排序 #定义空列表用于存放数据 res = [False]*len(str3) #用于存放索引值为偶数的字符 temp1 = [] #用于存放索引值为奇数的字符 temp2 = [] for k,v in enumerate(str3): if k % 2 == 0: temp1.append(v) else: temp2.append(v) #分别进行排序 temp1.sort() temp2.sort() for k in range(0,len(res)): if k % 2 == 0: res[k] = temp1[k//2] elif (k+1) % 2 == 0: res[k] = temp2[(k+1)//2-1] #此时res为排序后的列表 #倒序排列测试 # A1 = '1 2 3 4 5 6' # print(A1[::-1]) #temp3用于存放输出数据 temp3 = [] str1 = '1 2 3 4 5 6 7 8 9' str2 = 'a b c d e f A B C D E F' for word in res: if str(word) in str1 or str(word) in str2: #将每个字符转化为四位二进制数 word1 = fun1(word) #将四位二进制数按照比特位翻转 word2 = word1[::-1] #将翻转后的四位二进制数转化为十六进制数 word3 = fun2(word2) else: word3 = word temp3.append(str(word3)) print(''.join(temp3)) except: break