fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <iterator>
  5. #include <algorithm>
  6. #include <random>
  7.  
  8. int main()
  9. {
  10. std::vector<int> datas { 7, 1, 3, 5, 8, 2, 9, 4, 6 };
  11. std::map<int, std::vector<int>> m;
  12.  
  13. for (int i=0; i<10; ++i)
  14. {
  15. std::random_shuffle(datas.begin(), datas.end());
  16. m[i] = datas;
  17. }
  18.  
  19. for (auto it = m.begin(); it != m.end(); ++it)
  20. {
  21. std::copy(it->second.begin(), it->second.end(),
  22. std::ostream_iterator<int>(std::cout," "));
  23. std::cout << std::endl;
  24. }
  25.  
  26. for (auto it = m.begin(); it != m.end(); ++it)
  27. std::sort(it->second.begin(), it->second.end());
  28.  
  29. for (auto it = m.begin(); it != m.end(); ++it)
  30. {
  31. std::copy(it->second.begin(), it->second.end(),
  32. std::ostream_iterator<int>(std::cout," "));
  33. std::cout << std::endl;
  34. }
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
8 5 4 6 7 2 3 1 9 
8 4 2 1 9 7 6 5 3 
6 9 4 2 8 7 3 5 1 
1 5 2 8 4 3 6 7 9 
6 3 4 7 5 8 2 9 1 
4 7 1 2 5 6 9 3 8 
8 9 4 7 3 5 6 2 1 
7 3 4 5 2 9 1 8 6 
6 9 5 4 8 7 3 2 1 
3 6 7 2 4 1 5 9 8 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 9