练习:存放部门信息

#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;
class Employee
{
private:
    int id;
    string name;
public:
    Employee(int i, string n)
    {
        id = i;
        name = n;
    }
    void show()
    {
        cout << "工号: " << id << " 姓名: " << name << endl;
    }

};

int main(void)
{
    Employee e1(10, "aa");
    Employee e2(11, "ab");
    Employee e3(12, "ac");
    Employee e4(13, "ad");
    Employee e5(14, "af");
    Employee e6(15, "ag");
    Employee e7(16, "ah");
    Employee e8(17, "aj");
    multimap<string, Employee> m;
    //
    m.emplace("salse", e1);
    m.emplace("salse", e2);

    //
    m.insert(make_pair("delpment", e3));
    m.insert(make_pair("delpment", e4));

    //
    m.emplace(pair<string, Employee>("fans", e5));
    m.emplace(pair<string, Employee>("fans", e6));
    m.emplace(pair<string, Employee>("fans", e7));
    m.emplace(pair<string, Employee>("fans", e8));
    for(auto &l : m)
    {
        cout << "部门:" << l.first << " ";
        l.second.show();
    }
    return 0;
}
#include <iostream>
#include <stack>
#include <queue>

using namespace std;

int main(void)
{
    stack<int> s;
    for(int i=0; i<10; i++)
    {
        s.push(i);
    }
    cout << s.top() << endl;
    cout << s.size() << endl;

    cout << "________________" << endl;
    while(!s.empty())
    {
        cout << s.top() << endl;
        s.pop();
    }
    cout << "________________" << endl;
    queue<int> q;
    for(int i=0; i<10; i++)
    {
        q.push(i);
    }
    cout << q.front() << endl;
    cout << q.back() << endl;
    cout << q.size() << endl;

    cout << "________________" << endl;
    while(!q.empty())
    {
        cout << q.front() << endl;
        q.pop();
    }
    cout << "________________" << endl;


    priority_queue<int,deque<int>,less<int>> p;
    for(int i=0; i<10; i++)
    {
        p.emplace(i);
    }
    cout << p.top() << endl;
    cout << p.size() << endl;

    cout << "________________" << endl;
    while(!p.empty())
    {
        cout << p.top() << endl;
        p.pop();
    }
    cout << "________________" << endl;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值