题解 | #配置文件恢复#

配置文件恢复

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])

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-03 18:22
投了几百份简历,专业和方向完全对口,都已读不回。尝试改了一下学校,果然有奇效。
steelhead:这不是很正常嘛,BOSS好的是即便是你学院本可能都会和聊几句,牛客上学院本机会很少了
点赞 评论 收藏
分享
06-26 17:24
已编辑
宁波大学 golang
迷失西雅图:别给,纯kpi,别问我为什么知道
点赞 评论 收藏
分享
墨西哥大灰狼:如果你的校友卤馆还在的话,他肯定会给你建议的,可是卤馆注销了@ 程序员卤馆
点赞 评论 收藏
分享
完美的潜伏者许愿简历...:隐藏信息被你提取出来了,暗示,这就是暗示
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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