#define RIGHT 1 #define DOWN 2 #define LEFT 3 #define UP 4
int judge(int step, int walk, int flag) { if( walk < step )return flag; switch(flag) { case RIGHT: return DOWN; case DOWN: return LEFT; case LEFT: return UP; case UP: return RIGHT; } }
void matrix(int N) { int length = N * N; int *p = new int[length]; int flag = RIGHT; int step = N; int count = 0; int walk = -1; for(int i = 0 ; i < length ; i++) { walk += 1; int newflag = judge(step , walk , flag);