fork download
  1. #include <sstream>
  2. #include <iostream>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. struct Item
  7. {
  8. std::string word = "";
  9. std::vector<int> count = {0, 0, 0};
  10. };
  11. using Pair = std::pair<int, std::vector< std::pair<int, Item> > >;
  12.  
  13. int main()
  14. {
  15. std::vector< Pair > MyWords =
  16. { //int, <std::pair<int, Item > > >
  17. {1 , { { 4, Item{"String1", {1,2,3}} } } },
  18. {0 , { { 5, Item{"String2", {5,2,8}} } } },
  19. {2 , { { 8, Item{"String3", {1,7,9}} }, { 9, Item{"String4", {11,77,99}} } } }
  20. };
  21.  
  22.  
  23. for(const auto& bigPair: MyWords)
  24. {
  25. std::cout << "Key : " << bigPair.first;
  26.  
  27. for(const auto& smallPair: bigPair.second)
  28. {
  29. std::cout << "\nValues: " << smallPair.first << "\t";
  30.  
  31. std::cout << smallPair.second.word << " "
  32. << smallPair.second.count[0] << " "
  33. << smallPair.second.count[1] << " "
  34. << smallPair.second.count[2] ;
  35. }
  36. std::cout << "\n\n";
  37. }
  38.  
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 4316KB
stdin
Standard input is empty
stdout
Key : 1
Values: 4	String1 1 2 3

Key : 0
Values: 5	String2 5 2 8

Key : 2
Values: 8	String3 1 7 9
Values: 9	String4 11 77 99