fork download
  1. #include <map>
  2. #include <string>
  3. #include <iostream>
  4. #include <iomanip>
  5.  
  6. // for clarity:
  7. typedef std::string word_type ;
  8. typedef std::string tag_type;
  9.  
  10. int main()
  11. {
  12. std::map<word_type, std::map<tag_type, int>> wordcount;
  13.  
  14. wordcount["fly"]["V"] = 35;
  15. wordcount["fly"]["N"] = 150;
  16.  
  17. wordcount["fill"]["V"] = 49;
  18. wordcount["fill"]["N"] = 20;
  19.  
  20. wordcount["time"]["V"] = 19;
  21. wordcount["time"]["N"] = 90;
  22.  
  23. for (auto& tag : wordcount)
  24. {
  25. std::cout << std::left << std::setw(10) << tag.first << '\n';
  26.  
  27. for (auto & count : tag.second)
  28. {
  29. std::cout << std::setw(10) << "";
  30. std::cout << '[' << count.first << ']';
  31. std::cout << std::right << std::setw(5) << count.second << '\n';
  32. }
  33.  
  34. std::cout << '\n';
  35. }
  36. }
Success #stdin #stdout 0s 3436KB
stdin
Standard input is empty
stdout
fill      
          [N]   20
          [V]   49

fly       
          [N]  150
          [V]   35

time      
          [N]   90
          [V]   19