题解 | #配置文件恢复#

配置文件恢复

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

import sys
 
for line in sys.stdin:
    cmds = line.strip().split()
    cmd_set = ['reset', 'reset board', 'board add', 'board delete',
              'reboot backplane', 'backplane abort', 'he he']
    ops = ['reset what', 'board fault', 'where to add', 'no board at all',
          'impossible', 'install first', 'unknown command']
    flg = 0
    if len(cmds) == 1:
        if cmd_set[0].startswith(cmds[0]):
            print(ops[0])
        else:
            print(ops[-1])
    else:
        for i in range(1, len(cmd_set)):
            tmp_cmd = cmd_set[i].split()
            if tmp_cmd[0].startswith(cmds[0]) and tmp_cmd[1].startswith(cmds[1]):
				#保存操作
                OPS=ops[i]
                flg += 1
                # break
		#唯一匹配才操作成功,否则'unknown command'
        if flg == 1: print(OPS)
        else: print(ops[-1])

全部评论

相关推荐

程序员鼠鼠_春招版:我要12k吧我挂了,还招呢,天天被割,这点钱都不舍得出
点赞 评论 收藏
分享
秋国🐮🐴:拿到你简历编号然后让你知道世间险恶
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务