fork(1) download
  1.  
  2.  
  3. #include <stdio.h>
  4. #include <vector>
  5. #include <algorithm> // std::sort
  6.  
  7. #define N 10 //квадратная матрица
  8.  
  9. bool comp(int i,int j){ return (i<j); }
  10.  
  11.  
  12. int main(void) {
  13.  
  14.  
  15. std::vector<std::vector<int>> arr{
  16. {32,105,48,80,144,128,64,122,18,81},
  17. {66,129,113,17,94,78,90,51,104,34},
  18. {110,149,36,103,82,53,93,130,68,150},
  19. {41,19,124,61,85,159,115,57,72,101},
  20. {56,100,86,146,73,40,141,25,87,126},
  21. {151,71,94,15,125,76,54,99,39,140},
  22. {17,124,52,98,139,37,147,88,69,109},
  23. {35,128,67,30,93,123,50,138,21,97},
  24. {96,121,49,137,89,154,91,65,92,33},
  25. {-3, -21, 12, 45, 7, 43, 34, 89, 90, 100} //это 10ая строка
  26. };
  27.  
  28. for(int i=0; i<N; i++) //сортировка по увеличению в каждой строку
  29. std::sort(arr[i].begin(), arr[i].end());
  30.  
  31. for (int i=0; i<N; i++) {
  32. for (int j=0; j<N; j++) {
  33. printf("%4d", arr[i][j]);
  34. }
  35. printf("\n");
  36. }
  37.  
  38. return 0;
  39. }
  40.  
  41.  
Success #stdin #stdout 0s 4188KB
stdin
Standard input is empty
stdout
  18  32  48  64  80  81 105 122 128 144
  17  34  51  66  78  90  94 104 113 129
  36  53  68  82  93 103 110 130 149 150
  19  41  57  61  72  85 101 115 124 159
  25  40  56  73  86  87 100 126 141 146
  15  39  54  71  76  94  99 125 140 151
  17  37  52  69  88  98 109 124 139 147
  21  30  35  50  67  93  97 123 128 138
  33  49  65  89  91  92  96 121 137 154
 -21  -3   7  12  34  43  45  89  90 100