forked from jzplp/Cpp-Primer-Answer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11.23.cpp
38 lines (30 loc) · 862 Bytes
/
11.23.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
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<sstream>
#include<utility>
int main()
{
std::multimap<std::string, std::vector<std::pair<std::string, std::string>>> familys;
std::string line;
std::string fname, name, birth;
std::pair<std::string, std::string> child;
while(std::getline(std::cin, line))
{
std::istringstream is(line);
is >> fname;
std::vector<std::pair<std::string, std::string>> fam;
while(is >> name >> birth)
fam.push_back({name, birth});
familys.insert({fname, fam});
}
for(const std::pair<std::string, std::vector<std::pair<std::string, std::string>>> & p1 : familys)
{
std::cout << p1.first << std::endl;
for(const std::pair<std::string, std::string> &p2 : p1.second)
std::cout << p2.first << " " << p2.second << std::endl;
std::cout << std::endl;
}
return 0;
}