fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 10;
  5.  
  6. int main() {
  7. int n, mt[MAX_SIZE + 1][MAX_SIZE + 1];
  8. cin >> n;
  9. for (int i = 1; i <= n; ++i) {
  10. for (int j = 1; j <= n; ++j) {
  11. cin >> mt[i][j];
  12. }
  13. }
  14. ++n;
  15.  
  16. for (int i = n; i > 1; --i) {
  17. for (int j = 1; j < n; ++j) {
  18. if (i > n /2 + 1) {
  19. mt[i][j] = mt[i - 1][j];
  20. }
  21.  
  22. if (i == n / 2) {
  23. mt[i][j] = mt[j][n - 1];
  24. }
  25. }
  26.  
  27. }
  28.  
  29. for (int i = 1; i <= n; ++i) {
  30. for (int j = 1; j < n; ++j) {
  31. cout << mt[i][j] <<" ";
  32. }
  33. cout <<"\n";
  34. }
  35. /*
  36. 5
  37. 11 12 13 14 15
  38. 21 22 23 24 25
  39. 31 32 33 34 35
  40. 31 32 33 34 35
  41. 41 42 43 44 45
  42. 51 52 53 54 55
  43. */
  44.  
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0.01s 5296KB
stdin
5
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45
51 52 53 54 55

4
44 51 68 20
89 65 45 56
12 10 56 23
98 99 14 66
↓
stdout
11 12 13 14 15 
21 22 23 24 25 
15 25 35 45 45 
41 42 43 44 45 
41 42 43 44 45 
51 52 53 54 55