Using modulo to go to the firs column after the last column
ans [ i , j ] = arr [ j , ( i + j ) % n ] ; } } return ans ; } static void show ( int [ , ] arr , int n ) { int [ , ] res = solve ( arr , n ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { Console . Write ( res [ i , j ] + " ▁ " ) ; } Console . WriteLine ( ) ; } }