STL案例2-成员分组
发布日期:2022-03-04 12:48:33
浏览次数:29
分类:技术文章
本文共 1961 字,大约阅读时间需要 6 分钟。
黑马236
#include #include #include}
}
void showPerosn(multimap<int, person>& m) { cout << “策划部门” << endl; multimap<int, person>::iterator pos=m.find(chehua); int count = m.count(chehua); int index = 0; for (; pos != m.end() && index < count; pos++) { cout << “name” << pos->second.m_name << " salary:" << pos->second.m_salary << endl; index++; } cout << “美术部门” << endl; multimap<int, person>::iterator pos1 = m.find(meishu); int count1 = m.count(meishu); int index1 = 0; for (; pos1 != m.end() && index1 < count1; pos1++) { cout << “name” << pos1->second.m_name << " salary:" << pos1->second.m_salary << endl; index1++; } cout << “研发部门” << endl; multimap<int, person>::iterator pos2 = m.find(yanfa); int count2 = m.count(yanfa); int index2 = 0; for (; pos2 != m.end() && index2 < count2; pos2++) { cout << “name” << pos2->second.m_name << " salary:" << pos2->second.m_salary << endl; index2++; } } int main() { //创建员工 srand((unsigned int)time(NULL)); vector v; creatPerson(v); /测试/ //for (vector::iterator it = v.begin(); it != v.end(); it++) //{ // cout << “name:” << (*it).m_name << " salary:" << (*it).m_salary << endl; //}//员工分组multimapm;setGroup(v, m);//测试for (multimap ::iterator it = m.begin(); it != m.end(); it++)
{
cout << “key=”<first << “name:” << (*it).second.m_name << " salary:" << (*it).second.m_salary << endl; }//分组显示员工showPerosn(m);
}
转载地址:https://blog.csdn.net/qq_43752920/article/details/120532657 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2024年04月11日 00时41分57秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
git基础-01
2021-06-29
mysql-总结
2021-06-29
IPv4地址
2021-06-29
正则表达式
2021-06-29
redis
2021-06-29
术语-维护中
2021-06-29
software
2021-06-29
idea-ide
2021-06-29
technology
2021-06-29
spider-02
2021-06-29
spider-03
2021-06-29
spider-04
2021-06-29
spider-05
2021-06-29
spider-06
2021-06-29
spider-07
2021-06-29
Ubuntu环境配置
2021-06-29
CSDN日报190910:程序员都秃头,商务个个是人精
2021-06-29
CSDN日报190911:Unity3D开发小游戏;常见的五种神经网络
2021-06-29
CSDN博主排行榜上线!
2021-06-29
CSDN日报190912:前端、架构、数据库、游戏开发纯干货分享
2021-06-29