fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <map>
  5. using namespace std;
  6.  
  7. map<int ,vector<int> > mp;
  8. map<int, vector<int> >::iterator it;
  9. int main() {
  10. int n;
  11. cin>>n;
  12. for(int i=0;i<n;i++){
  13. int m;
  14. cin>>m;
  15. vector<int>v(m);
  16. for(int j=0;j<m;j++){
  17. cin>>v[j];
  18. }
  19. for(int j=0;j<m;j++){
  20. cout<<v[j]<<" ";
  21. }
  22. cout<<endl;
  23. mp.insert(make_pair(i,v));
  24. }
  25. for(it=mp.begin();it!=mp.end();it++){
  26. sort(it->second.begin(),it->second.end());
  27. }
  28. for(it=mp.begin();it!=mp.end();it++){
  29. int l=it->second.size();
  30. cout<<it->first<<"th sorted array-> ";
  31. for(int j=0;j<l;j++){
  32. cout<<it->second[j]<<" ";
  33. }
  34. cout<<endl;
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 3480KB
stdin
3
4
1 2 4 3
5
5 4 3 2 1
6
1 2 3 6 5 4
stdout
1 2 4 3 
5 4 3 2 1 
1 2 3 6 5 4 
0th sorted array-> 1 2 3 4 
1th sorted array-> 1 2 3 4 5 
2th sorted array-> 1 2 3 4 5 6