 拜托铠甲勇士真的帅好不好!!!
拜托铠甲勇士真的帅好不好!!!
STL案例2-员工分组
10个员工,指派部门,员工信息(姓名,工资组成,部门:策划,美术,研发),随机分配部门和公司,MULTIMAP插入信息,KEY部门编号,VAL员工,分部门显示员工信息
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<ctime>
using namespace std;
#define CEHUA 0
#define SHEJI 1
#define KAFA 2
class Worker {
public:
	Worker(string name, int salary) {
		this->_name = name;
		this->_sal = salary;
	}
public:
	string _name;
	int _sal;
};
void creatww(vector<Worker>& w) {
	srand((unsigned int)time(NULL));
	string nameseed = "ABCDEFGHIJ";
	for (int i = 0; i < 10; i++) {
		string name = "员工-";
		name += nameseed[i];
		int sal=rand() % 6001 + 7000;
		Worker p(name, sal);
		w.push_back(p);
	}
}
void setgroup(vector<Worker> w,multimap<int, Worker> &mw) {
	for (vector<Worker>::iterator it = w.begin(); it != w.end(); it++) {
		//产生随机部门编号
		int depid = rand() % 3;
		mw.insert(make_pair(depid, *it));
	}
}
void showgroup(multimap<int,Worker>&mw) {
	cout << endl;
	cout << "group CEHUA:\t" << endl;
	multimap<int, Worker>::iterator pos = mw.find(CEHUA);
	int count = mw.count(CEHUA);//统计具体人数
	int index = 0;
	for (; pos != mw.end() && index < count; pos++, index++) {//pos->first!=CEHUA不对脑子清醒了再试
		cout << pos->second._name << " " << pos->second._sal << endl;
	}
	cout << endl;
	cout << "group SHEJI:\t" << endl;
	pos = mw.find(SHEJI);
	count = mw.count(SHEJI);//统计具体人数
	index = 0;
	for (; pos != mw.end() && index < count; pos++, index++) {
		cout << pos->second._name << " " << pos->second._sal << endl;
	}
	cout << endl;
	cout << "group KAFA:\t" << pos->first << endl;
	pos = mw.find(KAFA);
	count = mw.count(KAFA);//统计具体人数
	index = 0;
	for (; pos != mw.end() && index < count; pos++, index++) {
		cout << pos->second._name << " " << pos->second._sal << endl;
	}
}
void tst01() {
	vector<Worker>w;
	creatww(w);
	for (vector<Worker>::iterator it = w.begin(); it != w.end(); it++) {
		cout << it->_name << " " << it->_sal << endl;
	}
	cout << endl;
	multimap<int, Worker>mw;
	setgroup(w,mw);
	showgroup(mw);
}
int main() {
	tst01();
	system("pause");
	return 0;
}



![[Cmake Qt]找不到文件ui_xx.h的问题?有关Qt工程的问题,看这篇文章就行了。](https://img-blog.csdnimg.cn/direct/4d470e5051ee4aa4918a1c7adee44b25.png)

![OSError: [WinError 1455] 页面文件太小,无法完成操作 的问题](https://img-blog.csdnimg.cn/direct/d52aea30ffa6436dae61333fdd4dcd34.png)













