Given a matrix, print all elements in spiral order.
Given a positive integer n, generate a square matrix filled with elements from 1 to n^2 in spiral order.