在n×n方阵里填入1、2、3……n×n,要求填成盘蛇形。例如n=4时为:
10 11 12 01
09 16 13 02
08 15 14 03
07 06 05 04
在上面的方阵中,小于10的数前面都补足0,数与数之间有一个空格。
Input
n (n<=9)
Output
盘蛇形方阵
Sample Input
4
Sample Output
10 11 12 01
09 16 13 02
08 15 14 03
07 06 05 04
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mm(a) memset(a,0,sizeof(a))
#define max(x,y) (x)>(y)?(x):(y)
#define min(x,y) (x)<(y)?(x):(y)
const int INF = 0x3f3f3f3f;
const int MAXN = INF;
int a[11][11],dirx[4]= {