diff options
author | Oskar <[email protected]> | 2024-10-06 21:28:38 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-10-06 21:28:38 +0200 |
commit | 0921163e1f88c8e80991f0c94e0fc70c6dcba72d (patch) | |
tree | 878b49f5971e6469b9bb65e5c69ce37644ad8730 /8p11.cpp | |
parent | 19419d86cb88981df7973b08a0da6373abfba566 (diff) |
more
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; +} |