-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path11.14.cpp
36 lines (29 loc) · 833 Bytes
/
11.14.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
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<sstream>
#include<utility>
int main()
{
std::map<std::string, std::vector<std::pair<std::string, std::string>>> familys;
std::string line;
std::string name, birth;
std::pair<std::string, std::string> child;
while(std::getline(std::cin, line))
{
std::istringstream is(line);
is >> name;
std::vector<std::pair<std::string, std::string>> &fam = familys[name];
while(is >> name >> birth)
fam.push_back({name, birth});
}
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;
}