fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <string>
  5.  
  6. int main ()
  7. {
  8.  
  9. std::map<std::string, std::vector<float> > m_data;
  10. std::vector<float> m_mass{1.0,3.0,5.0,7.0};
  11. std::vector<float> m_velocity{1.0,3.0,5.0,7.0};
  12. std::vector<unsigned int> m_charge{2,4,6,8};
  13. m_data.insert(std::make_pair("mass", m_mass) );
  14. m_data.insert(std::make_pair("velocity",m_velocity) );
  15. m_data.insert(std::make_pair("charge", std::vector<float>(
  16. m_charge.begin(), m_charge.end())) );
  17. for(const auto p: m_data) {
  18. std::cout << p.first << ": ";
  19. for(const auto& n: p.second)
  20. std::cout << n << ' ';
  21. std::cout << '\n';
  22. }
  23. }
  24.  
Success #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
charge: 2 4 6 8 
mass: 1 3 5 7 
velocity: 1 3 5 7