当前位置:网站首页>练习:存放部门信息
练习:存放部门信息
2022-07-29 05:24:00 【阿童沐游】
#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;
}
边栏推荐
- 关于时间复杂度的个人看法
- LeetCode #83. 删除排序链表中的重复元素
- 传统模型预测控制轨迹跟踪——圆形轨迹(功能包已经更新)
- leetcode刷题笔记 763.划分字母区间(中等)
- Leetcode 14. longest public prefix
- LeetCode #26.删除有序数组中的重复项
- Install MySQL from scratch (MySQL installation document - unzipped version)
- IDEA 实用快捷键 新手必看
- 位运算学习笔记
- Jingwei Qili: OLED character display based on hmep060 (and Fuxi project establishment demonstration)
猜你喜欢
随机推荐
Leetcode 557. reverse word III in string
Linked list -------------------------- tail insertion method
LeetCode #35.搜索插入位置
Maya ACES工作流程配置(Arnold 及 RedShift 贴图配置规范-还原出SP-Aces流程下贴图正确的效果) PS还原Aces流程下渲染的图
Leetcode scribble notes 763. Divide the letter range (medium)
LeetCode #3.无重复字符的最长子串
UE5 光影基础 阴影全解析 锯齿阴影解决方案 Lumen
多线程和并发
JUC集合类不安全
Leetcode 14. longest public prefix
Abstract classes and interfaces
LeetCode #26.删除有序数组中的重复项
Learning notes of bit operation
Markdown and typora
Leetcode 977. Square of ordered array
Multithreading and concurrency
Leetcode 344. reverse string
Open source based on STM32: MHD Bluetooth speaker (including source code +pcb)
Jingwei Qili: OLED character display based on hmep060 (and Fuxi project establishment demonstration)
动态规划总结