题解 | #配置文件恢复#

配置文件恢复

https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5

import sys
mingling = [['reset'],['reset','board'],['board','add'],['board','delete'],['reboot','backplane'],['backplane','abort']]
zhixin = [['reset what'],['board fault'],['where to add'],['no board at all'],['impossible'],['install first'],['unknown command']]
while True:
    try:
        #输入命令
        n_sec = list(input().split())
        n = len(n_sec)
        #根据命令的长度判断
        if n == 1:
            m = len(n_sec[0])
            if n_sec[0] == mingling[0][0][0:m]:
                print(zhixin[0][0])
            else:
                print(zhixin[6][0])
        elif n == 2:
            m, k = len(n_sec[0]), len(n_sec[1])

            l = 6
            go_dowm = True
            for i in range(1,6):
                if n_sec[0] == mingling[i][0][0:m] and n_sec[1] == mingling[i][1][0:k]:
                        if l == 6:
                            l = i
                        else:
                            print(zhixin[6][0])
                            go_dowm = False
                            break
            if  go_dowm:
                print(zhixin[l][0])
            
        else:
            print(zhixin[6][0])
    except:
        break

全部评论

相关推荐

hso_:哈哈哈哈哈哈我没offer一样在同一道题开喷了
投递深圳同为数码等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务