#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;
}