题解 | #配置文件恢复#

配置文件恢复

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

// HJ66-2 配置文件恢复.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
#include<iostream>
#include<bits/stdc++.h>

using namespace std;

int main()
{
	string str;
	string signal = "reset";
	vector<vector<string>>dp = { {"reset","board","board fault"},{"board","add","where to add"},
		{"board","delete","no board at all"},{"reboot","backplane","impossible"},{"backplane","abort","install first"} };
	while (getline(cin, str))
	{
		int n = count(str.begin(),str.end(),' ');
		if (n == 0)
		{
			if (signal.find(str) == 0)
			{
				cout << "reset what" << endl;
			}
			else
			{
				cout << "unknown command" << endl;
			}
		}
		else
		{
			int count = 0; string res = "";
			int x = str.find(' ');
			string str1 = str.substr(0, x);
			string str2 = str.substr(x + 1);
			for (int i = 0; i < 5; i++)
			{
				if (dp[i][0].find(str1) == 0 && dp[i][1].find(str2) == 0)
				{
					res = dp[i][2];
					count++;
					continue;
				}
			}
			if (count == 1)
			{
				cout << res << endl;
			}
			else
			{
				cout << "unknown command" << endl;
			}
		}
	}
	return 0;
}

全部评论

相关推荐

点赞 评论 收藏
分享
DKS233:项目写太简单了,你用什么技术实现了什么功能,优化了多少,分了哪些模块,解决了哪些难点,最好分模块写,你写的太模糊了。精通还是少用吧,你确定问你底层你扛的住吗,最好用熟悉。具备良好**意识,这种空话不要写,技能层面,要写就写实在的,比如“熟悉常用数据结构,如,堆,栈,链表,哈希表,平衡树”这种
你的简历改到第几版了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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