diff options
Diffstat (limited to '8p11.cpp')
-rw-r--r-- | 8p11.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/8p11.cpp b/8p11.cpp new file mode 100644 index 0000000..267e692 --- /dev/null +++ b/8p11.cpp @@ -0,0 +1,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(auto &a : people) { + std::cout << a.name << "\n"; + for(auto &b : a.phones) { + std::cout << b << "\n"; + } + } + + return 0; +} |