题解 | 牛牛的考试

牛牛的考试

https://www.nowcoder.com/practice/1a7a7c8d721547a29107cf02330ffe72

T=int(input())
for x in range(T):
    A=input()
    B=input()
    C=input()
    D=input()
    l=[len(A),len(B),len(C),len(D)]
    G={'0':'A','1':'B','2':'C','3':'D'}
    if l.count(min(l))==1 and l.count(max(l))!=1:
        s=l.index(min(l))
    elif l.count(max(l))==1 and l.count(min(l))!=1:
        s=l.index(max(l))
    else:
        s=2
    print(G[str(s)])
#情况 1:如果最小值唯一且最大值不唯一 → 选最短的那个(索引 s)

#情况 2:如果最大值唯一且最小值不唯一 → 选最长的那个(索引 s)

#否则(其他情况)→ 固定选索引 2(即字符串 C)
        



全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务