10236 - Lab06   

Description

Given a number N, we can create an N by N matrix as below:
  1   2   3   4   5 
 16  17  18  19   6 
 15  24  25  20   7 
 14  23  22  21   8 
 13  12  11  10   9 

In this case, N = 5, and the elements are in order from 1 to N2 as a clockwise spiral pattern.
Note that we always start from the upper left corner.

Now we have a sequence of numbers, please print the corresponding matrices.

Input

A sequence of numbers, each number N indicates the size of matrix. (1 <= N <= 20)
The input is terminated by a newline '\n'.

Output

The matrices corresponding to the input.
Use "%3d " to printf each element. Print a newline '\n' at the end of each row. 

Sample Input  Download

Sample Output  Download

Tags




Discuss