swap elements of diagonal
for ( let i = 0 ; i < N ; ++ i ) if ( i != parseInt ( N / 2 ) ) { let temp = array [ i ] [ i ] ; array [ i ] [ i ] = array [ i ] [ N - i - 1 ] ; array [ i ] [ N - i - 1 ] = temp ; } for ( let i = 0 ; i < N ; ++ i ) { for ( let j = 0 ; j < N ; ++ j ) document . write ( " " + array [ i ] [ j ] ) ; document . write ( " " ) ; } }