Python 代码实现:

while True:
    try:
        head_1, head_2 = input().split('-')
        hand_dict = {'3':0,'4':1,'5':2,'6':3,'7':4,'8':5,'9':6,'10':7,'J':8,
             'Q':9,'K':10,'A':11,'2':12,'joker':13,'JOKER':14}
        if head_1 == 'joker JOKER' or head_2 == 'joker JOKER':
            print('joker JOKER')
        elif len(head_1.split()) == len(head_2.split()):
            print(head_1 if hand_dict[head_1.split()[0]] > hand_dict[head_2.split()[0]] else head_2)
        elif len(head_1.split()) == 4:
            print(head_1)
        elif len(head_2.split()) == 4:
            print(head_2)
        else:
            print('ERROR')
    except:
        break