fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <vector>
  4. #include <thread>
  5. #include <fstream>
  6. #include <utility>
  7. #include <map>
  8.  
  9. using namespace std;
  10.  
  11.  
  12. int main()
  13. {
  14.  
  15. std::map<std::string, std::vector<int> > m;
  16.  
  17. m["AA"] = {1, 2, 3, 1, 2, 1, 2, 3};
  18. m["BB"] = {2, 3, 4, 1, 2, 3, 4, 5, 5 };
  19. m["CC"] = {2, 3, 4, 1, 2, 3, 4, 5};
  20.  
  21. size_t size = 0;
  22. for (auto item = m.begin(); item != m.end(); ++item)
  23. {
  24. std::cout << item->first << '\t';
  25. if (size < item->second.size())
  26. {
  27. size = item->second.size();
  28. }
  29. }
  30.  
  31. std::cout << std::endl;
  32.  
  33. for (size_t i = 0; i< size; i++)
  34. {
  35. for (auto item = m.begin(); item != m.end(); ++item)
  36. {
  37. if (i < item->second.size())
  38. {
  39. std::cout << item->second.at(i) << '\t';
  40. }
  41. }
  42. std::cout << std::endl;
  43. }
  44.  
  45. return 0;
  46. }
Success #stdin #stdout 0s 3024KB
stdin
Standard input is empty
stdout
AA	BB	CC	
1	2	2	
2	3	3	
3	4	4	
1	1	1	
2	2	2	
1	3	3	
2	4	4	
3	5	5	
5