哔哩哔哩后台服务器端笔试--第三题 20%啥情况啊

#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;
void splitstring(const string& srcstr, vector<string>& vec, const string& separator)
{
	string::size_type possubstringstart;
	string::size_type posseparator;
	posseparator = srcstr.find(separator);
	possubstringstart = 0;
	while (string::npos != posseparator)
	{
		vec.push_back(srcstr.substr(possubstringstart, posseparator - possubstringstart));
		possubstringstart = posseparator + separator.size();
		posseparator = srcstr.find(separator, possubstringstart);
	}
	if (possubstringstart != srcstr.length())
		vec.push_back(srcstr.substr(possubstringstart));
}
int main()
{
	vector<string> input, input1;
	string tmp;
	map<string, string> mpout;
	getline(cin, tmp, '\n');
	splitstring(tmp, input, " ");
	string tmp1 = input[0];
	string tmp2 = input[1];
	splitstring(input[2], input1, tmp1);
	int len = input1.size();
	cout << len << endl;
	for (int i = 0; i < len; i++)
	{
		//cout << input1[i] << endl;
		vector<string> input2;
		splitstring(input1[i], input2, tmp2);
		mpout.insert(pair<string, string>(input2[0], input2[1]));
	}
	for (map<string, string>::iterator it = mpout.begin(); it != mpout.end(); it++)
	{
		if (!it->first.empty() && !it->second.empty())
		cout << it->first << " " << it->second << endl;
	}
	return 0;
}

#笔试题目##哔哩哔哩#
全部评论
还有 老哥你这代码写的太复杂了吧,看起来太难懂了  这是我的代码 你可以借鉴一下,看看哪里有问题 #include<bits/stdc++.h> using namespace std; #define pii pair<string,string> int main(){   char f,k;   cin>>f>>k;   string s;   cin>>s;   vector<pii>vq;   bool fa = 0 ;   string x,y;   for(int j=0;j<s.size();j++){      if(s[j]==k){         fa = 1;         continue;      }      if(s[j]==f){         fa = 0;         if(x.size()>0&&y.size()>0)           vq.push_back(make_pair(x,y));         x="";         y="";         continue;      }      if(!fa){        x+=s[j];      }else{        y+=s[j];      }   }   if(x.size()>0&&y.size()>0)      vq.push_back(make_pair(x,y));   cout<<vq.size()<<endl;   for(pii p:vq){     cout<<p.first<<" "<<p.second<<endl;   } } /* # : a:dasd3#bsda:asda8 */
点赞 回复 分享
发布于 2019-09-10 22:31
判空 有可能 #c#   ###
点赞 回复 分享
发布于 2019-09-10 21:16
我估计再加个判断 就A了
点赞 回复 分享
发布于 2019-09-10 21:03
同20%,做了40分钟,然后8点有面试,直接提交了
点赞 回复 分享
发布于 2019-09-10 21:03
直接输出测试用例 80%
点赞 回复 分享
发布于 2019-09-10 21:01

相关推荐

smile丶snow:感觉可以加一些ai相关的内容吧。现在面试很少能逃掉这些问题。羡慕里面感觉缺少一个项目背景。比如第二个项目后台管理系统…你为什么要做这个后台管理系统呢?是为了解决什么问题。比如你管理一个商品列表的增加减少。需要一个背景吧。哦或者说你第一个电子书那个是c端的,你肯定需要一个管理系统吧,那就是第二个后台管理系统,但这两个难道不应该是一个项目吗?可以稍微包装一下,最起码让人看着不是玩具项目。个人观点。
点赞 评论 收藏
分享
03-15 10:59
已编辑
美团_后端开发(实习员工)
爱写代码的菜code...:哎,自己当时拿到字节offer的时候也在感叹终于拿到了,自己当时最想去的企业就是字节,结果还是阴差阳错去了鹅厂。祝uu一切顺利!!!
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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