1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| int main() {
multimap<string, string>authors{ { "alan", "DMA" }, { "pezy", "LeetCode" }, { "alan", "CLRS" }, { "wang", "FTP" }, { "pezy", "CP5" }, { "wang", "CPP-Concurrency" } };
map<string, multiset<string>> order_authors; for (const auto& author : authors) order_authors[author.first].insert(author.second); for (const auto& author : order_authors) { cout << author.first << ": "; for (const auto& work : author.second) cout << work << " "; cout << std::endl; } system("pause"); return 0; }
|