Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WORD WORD2
- WORD3 WORD4
- WORD5
- WORD6
- #include <string>
- #include <sstream>
- #include <iostream>
- #include <vector>
- #include <map>
- std::map<std::string, std::string> m;
- std::vector<std::string> v;
- for (std::string line; std::getline(std::cin, line); )
- {
- if (line.empty()) { break; }
- std::string x, y;
- std::istringstream iss(line);
- if (!(iss >> x >> y >> std::ws)) { /* fatal error */ }
- m[x] = y;
- }
- for (std::string line; std::getline(std::cin, line); )
- {
- v.push_back(std::move(line));
- }
- std::cout << "We read " << m.size() << " pairs and " << v.size() << " words.n";
- if (!(iss >> x >> y >> std::ws) || iss.get() != EOF) { /* fatal error */ }
Add Comment
Please, Sign In to add comment