Problem Matrix detour: Spiral
Statement
Your program must fill the
N by
N square matrix
with integers from 1 to
N2; in the following way:
- 1 must be in the top left corner;
- increasing seqeunce of numbers must form a spiral, twisted clockwise and inside.
Input file format
Input file contains an integer
N.
Output file format
Output file must contain the filled matrix as
N lines consisting of
N integers each.
Constraints
1 <=
N <= 100
Sample tests
No. |
Input file (input.txt ) |
Output file (output.txt ) |
1 |
2
|
1 2
4 3
|
2 |
3
|
1 2 3
8 9 4
7 6 5
|