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

PROGRAMMING:Spiral matrix

Luz5年前 (2021-05-10)题库387
The so-called "spiral square matrix" means that for any given n, 1 to n × The number of N starts from the first grid in the upper left corner and fills in N in the order of clockwise spiral × In the square of n. This problem requires the construction of such a spiral matrix.
###Input format:
Input gives a positive integer n (< = 30) on a line.
###Output format:
Output n × The spiral matrix of n. There are n numbers in each line, and each number occupies 3 digits.
###Input example:
```in
ten
```
###Output example:
```out
001 002 003 004 005 006 007 008 009 010
036 037 038 039 040 041 042 043 044 011
035 064 065 066 067 068 069 070 045 012
034 063 084 085 086 087 088 071 046 013
033 062 083 096 097 098 089 072 047 014
032 061 082 095 100 099 090 073 048 015
031 060 081 094 093 092 091 074 049 016
030 059 080 079 078 077 076 075 050 017
029 058 057 056 055 054 053 052 051 018
028 027 026 025 024 023 022 021 020 019
```







answer:If there is no answer, please comment