int k = n / 2; int l = c / 2; for (int i = 0; i <= k; i++) { for (int j = 0; j <= l; j++) { int temp = a[i][j]; a[i][j] = a[i + k][j + l]; a[i + k][j + l] = temp; cout << temp << " "; } }
int k = (n + 1) / 2;
int l = (c + 1) / 2;
for (int i = 0; i < n / 2; i++)
{
for (int j = 0; j < c / 2; j++)
{
int temp = a[i][j];
a[i][j] = a[i + k][j + l];
a[i + k][j + l] = temp;
cout << temp << " ";
}
}