fork download
  1. #include <vector>
  2. #include <algorithm>
  3. #include <iostream>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. vector<vector<int>> arr{
  9. {32,105,48,80,144,128,64,122,18,81},
  10. {66,129,113,17,94,78,90,51,104,34},
  11. {110,149,36,103,82,53,93,130,68,150},
  12. {41,19,124,61,85,159,115,57,72,101},
  13. {56,100,86,146,73,40,141,25,87,126},
  14. {151,71,94,15,125,76,54,99,39,140},
  15. {17,124,52,98,139,37,147,88,69,109},
  16. {35,128,67,30,93,123,50,138,21,97},
  17. {96,121,49,137,89,154,91,65,92,33},
  18. {-3, -21, 12, 45, 7, 43, 34, 89, 90, 100} //это 10ая строка
  19. };
  20.  
  21. int main(int argc, const char * argv[])
  22. {
  23. int n = 10;
  24. vector<int> flat;
  25. for(int i = 0; i < n; ++i)
  26. for(int j = 0; j < n; ++j)
  27. flat.push_back(arr[i][j]);
  28.  
  29. sort(flat.begin(),flat.end());
  30.  
  31. for(int i = 0; i < n; ++i)
  32. copy_n(flat.begin()+i*n,n,arr[i].begin());
  33.  
  34. for(auto a: arr)
  35. {
  36. for(auto b: a) cout << setw(4) << b << " ";
  37. cout << endl;
  38. }
  39.  
  40.  
  41. }
  42.  
Success #stdin #stdout 0s 4320KB
stdin
Standard input is empty
stdout
 -21   -3    7   12   15   17   17   18   19   21 
  25   30   32   33   34   34   35   36   37   39 
  40   41   43   45   48   49   50   51   52   53 
  54   56   57   61   64   65   66   67   68   69 
  71   72   73   76   78   80   81   82   85   86 
  87   88   89   89   90   90   91   92   93   93 
  94   94   96   97   98   99  100  100  101  103 
 104  105  109  110  113  115  121  122  123  124 
 124  125  126  128  128  129  130  137  138  139 
 140  141  144  146  147  149  150  151  154  159