#4697. 蛇形填数

蛇形填数

Description

&nbsp;&nbsp;&nbsp; <strong>例5.13 &nbsp;</strong>蛇形填数

&emsp; &nbsp; &nbsp;在n*n方阵里填入1&#44;2&#44;3&#44;…&#44;n*n,要求填成蛇形。例如n=4时方阵为:

&emsp; &nbsp; 10 11 12 &nbsp;1

&emsp; &nbsp; &nbsp;9 &nbsp;16 13 &nbsp;2

&emsp; &nbsp; &nbsp;8 &nbsp;15 14 &nbsp;3

&emsp; &nbsp; &nbsp;7 &nbsp; &nbsp;6 &nbsp; 5 &nbsp;4

&nbsp;&nbsp;&nbsp; 上面的方阵中,多余的空格只是为了便于观察规律,不必严格输出,n&lt;=8。

<br />

Input Format

    一个整数n,n8。

Output Format

    n行,每行n个整数,用空格分隔。
4
10 11 12 1
9 16 13 2
8 15 14 3
7 6 5 4

Source

二维数组