-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path32.cpp
53 lines (46 loc) · 1.13 KB
/
32.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <typeinfo>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::multimap;
using std::map;
using std::vector;
using std::multiset;
void print(multimap<string, string> works, string info = ""){
cout << "---" << info << "---" << endl;
for(auto &i : works){
cout << i.first << " " << i.second << endl;
}
}
bool compare(string s1, string s2){
return s1 < s2;
}
int main(){
std::multimap<string, string> authors;
authors = {
{ "alan", "DMA" },
{ "pezy", "LeetCode" },
{ "alan", "CLRS" },
{ "wang", "FTP" },
{ "pezy", "CP5" },
{ "wang", "CPP-Concurrency" }
};
map<string, multiset<string>> order_authors;
for(const auto &i : authors){
order_authors[i.first].insert(i.second);
}
// cout << "type test : " << typeid(order_authors["alan"]).name() << endl;
for(const auto &author : order_authors){
cout << author.first << " has works: ";
for(const auto &work : author.second){
cout << work << " ";
}
cout << endl;
}
}