for(int i = 0; i < M/2; i++)
for(int j = 0; j < N/2; j++)
{
var temp = array[i,j];
array[i,j] = array[M/2 + i,N/2 + j];
array[M/2 + i,N/2 + j] = temp;
}
for(int i = 0; i < M/2; i++)
for(int j = 0; j < N/2; j++)
{
var temp = array[i,j];
array[i,j] = array[M/2 + i,N/2 + j];
array[M/2 + i,N/2 + j] = temp;
}