-->
当前位置:首页 > 题库

PROGRAMMING:Spiral matrix

Luz5年前 (2021-05-10)题库501
The so-called "spiral square matrix" refers to that for any given $$n $, the numbers from 1 to $$n times n $, starting from the first lattice in the upper left corner, are filled into the square matrix of $$n times n $, in a clockwise spiral direction. This problem requires the construction of such a spiral matrix.
###Input format:
Input gives a positive integer $$n $$($< 10 $$) in one line.
###Output format:
Output the spiral matrix of $$n times n $. There are $$n $$numbers in each line, and each number occupies 3 digits.
###Input example:
```in
five
```
###Output example:
```out
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
```






answer:If there is no answer, please comment