Guest User

Untitled

a guest
Jan 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. WORD WORD2
  2. WORD3 WORD4
  3.  
  4. WORD5
  5. WORD6
  6.  
  7. #include <string>
  8. #include <sstream>
  9. #include <iostream>
  10. #include <vector>
  11. #include <map>
  12.  
  13. std::map<std::string, std::string> m;
  14. std::vector<std::string> v;
  15.  
  16. for (std::string line; std::getline(std::cin, line); )
  17. {
  18. if (line.empty()) { break; }
  19.  
  20. std::string x, y;
  21. std::istringstream iss(line);
  22.  
  23. if (!(iss >> x >> y >> std::ws)) { /* fatal error */ }
  24.  
  25. m[x] = y;
  26. }
  27.  
  28. for (std::string line; std::getline(std::cin, line); )
  29. {
  30. v.push_back(std::move(line));
  31. }
  32.  
  33. std::cout << "We read " << m.size() << " pairs and " << v.size() << " words.n";
  34.  
  35. if (!(iss >> x >> y >> std::ws) || iss.get() != EOF) { /* fatal error */ }
Add Comment
Please, Sign In to add comment