【C++】员工排序,vector、multimap

#include<iostream>
using namespace std;
#include"list"
#include<algorithm>
#include"vector"
#include"string.h"
#include"map"
#include"ctime"
#define CEHUA 0 
#define MEISHU 1 
#define YANFA 2

class Worker {
public:
	string m_name;
	int m_salary;
};


void creatworker(vector<Worker>& v) {
	string nameseed = "ABCDE";
	for (int i = 0; i < 5; i++) {
		Worker worker;
		worker.m_name = "员工";
		worker.m_name += nameseed[i];
		worker.m_salary = rand() % 10000 + 10000;
		
		v.push_back(worker);
	}

}

void setgroup(vector<Worker>& v,multimap<int,Worker>& m) {
	for (vector<Worker>::iterator it = v.begin(); it != v.end(); it++) {
		int depid = rand() % 3;
		m.insert(make_pair(depid, *it));

	}

}

void printgroup(multimap<int,Worker>& m) {
	cout << "策划部门:" << endl;

	multimap<int, Worker>::iterator pos = m.find(CEHUA);
	int  count = m.count(CEHUA);
	for (int index = 0;pos!=m.end()&&index <count;pos++, index++) {
		cout << pos->second.m_name << " " << pos->second.m_salary;
	}
	cout << endl;



	cout << "美术部门:" << endl;

	 pos = m.find(MEISHU);
	int  count2 = m.count(MEISHU);
	for (int index = 0; pos != m.end() && index < count2; pos++,index++) {
		cout << pos->second.m_name << " " << pos->second.m_salary;
	}
	cout << endl;


	cout << "研发部门:" << endl;

	 pos = m.find(YANFA);
	int  count3 = m.count(YANFA);
	for (int index = 0; pos != m.end() && index < count3; pos++,index++) {
		cout << pos->second.m_name << " " << pos->second.m_salary;
	}
	cout << endl;

}

int main() 
{
	srand((unsigned)time(NULL));
	vector<Worker>vworker;
	creatworker(vworker);
	
	for (vector<Worker>::iterator it = vworker.begin(); it != vworker.end(); it++) {
		cout << "姓名" << it->m_name << " " << it->m_salary << " " << endl;
	}
	
	multimap<int, Worker>mworker;
	setgroup(vworker, mworker);

	printgroup(mworker);
	system("pause");
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
员工管理系统】 问题描述:每个员工的信息包括:编号、姓名、性别、出生年月、学历、职务、电话、住址等。系统能够完成员工信息的查询、更新、插入、删除、排序等功能。 基本要求:排序:按不同关键字,对所有员工的信息进行排序;查询:按特定条件查找员工;更新,按编号对某个员工的某项信息进行修改;插入,加入新员工的信息;删除,按编号删除已离职的员工的信息。 选作内容:实现图形用户界面。 通过链表实现 数据结构: #include #include #include #include #include using namespace std; typedef struct workers{ char name[15];//姓名 char department[18];//单位 char gender;//性别 unsigned int age;//年龄 unsigned long long telephone;//电话 unsigned long wage;//工资 unsigned long num;//职工号 struct workers *next; }*Linklist,Lnode; void frist_print() { printf("\t\t⊙▽⊙ ⊙▽⊙ ⊙▽⊙ ⊙▽⊙ ⊙▽⊙ ⊙▽⊙ \n\n"); printf("\t\t\t欢迎进入员工管理系统\n"); } void menu() { printf("\n\t\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); printf("\t\t \t ◎1.创建员工信息\t \n"); printf("\t\t \t ◎2.插入员工信息\t \n"); printf("\t\t \t ◎3.修改员工信息\t \n"); printf("\t\t \t ◎4.删除员工信息\t \n"); printf("\t\t \t ◎5.查询员工信息\t \n"); printf("\t\t \t ◎6.员工信息排序\t \n"); printf("\t\t \t ◎7.显示员工信息\t \n"); printf("\t\t \t ◎8.员工工资情况\t \n"); printf("\n\t\t^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); printf("注意:输入均以回车作为结束\n"); printf("please choise 1--8:\t "); //putchar(12); } void Inset(Linklist Head){ Linklist s,L; unsigned int agee; unsigned long wagee,numm;

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

喜欢唱跳有错吗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值