http://blogs.msdn.com/oldnewthing/archive/2008/09/02/8918130.aspx

for(i=0;i<N;i++) for(j=0;j<M;j++) b[j][N-i]=a[i][j];