forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
30 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
//! @Alan | ||
//! | ||
//! | ||
//! Exercise 11.32: | ||
//! Using the multimap from the previous exercise, write a program to | ||
//! print the list of authors and their works alphabetically. | ||
//! | ||
// | ||
// ex11_32.cpp | ||
// Exercise 11.32 | ||
// | ||
// Created by pezy on 12/17/14. | ||
// Copyright (c) 2014 pezy. All rights reserved. | ||
// | ||
// Using the multimap from the previous exercise, write a program to print the list of **authors and their works** alphabetically. | ||
|
||
#include <iostream> | ||
#include <map> | ||
#include <set> | ||
#include <string> | ||
#include <algorithm> | ||
#include <vector> | ||
|
||
#include <iostream> | ||
|
||
using std::string; | ||
|
||
int main() | ||
{ | ||
//! define and initialize the multimap | ||
std::multimap<std::string, std::string> m = {{"lan","z111"},{"alan","a112"},{"Alan","a113"},{"cWang","g222"}}; | ||
|
||
//! print the map without sorting | ||
for(const auto &e : m) | ||
std::cout << e.first << " " << e.second << "\n"; | ||
std::cout << "\n"; | ||
|
||
|
||
|
||
return 0; | ||
} | ||
|
||
std::multimap<string, string> map{ | ||
{"alan", "DMA"}, | ||
{"pezy", "LeetCode"}, | ||
{"alan", "CLRS"}, | ||
{"wang", "FTP"}, | ||
{"pezy", "CP5"}, | ||
{"wang", "CPP-Concurrency"} | ||
}; | ||
std::map<string, std::multiset<string>> ordermap; | ||
for (const auto &e : map) | ||
ordermap[e.first].insert(e.second); | ||
for (const auto &e : ordermap) { | ||
std::cout << e.first << ": "; | ||
for (const auto &work : e.second) | ||
std::cout << work << " "; | ||
std::cout << std::endl; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.