summaryrefslogtreecommitdiff
path: root/8p11.cpp
blob: 49a78252e9888f0e550483c2e4311488978177cd (plain)
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
#include <iostream>
#include <vector>
#include <sstream>

/*
 *
 * 8.11
 *
 *
 */

struct PersonInfo {
	std::string name;
	std::vector<std::string> phones;
};

int main () {

	std::string line;
	std::string word;
	std::vector<PersonInfo> people;
	std::istringstream record;
	while (getline(std::cin, line)) {
		PersonInfo info;
		record.clear(); 
		record.str(line);
		record >> info.name; // read the name
		while (record >> word) {
			info.phones.push_back(word);
		}
		
		people.push_back(info);
	}

	for(const auto &a : people) {
		std::cout << a.name << "\n";
		for(const auto &b : a.phones) {
			std::cout << b << "\n";
		}
	}
	
	return 0;
}