#include int main(void){ int N; int box[30][30] = {0}; int count = 1; scanf("%d",&N); int start = 0; int end = N; /* // left to right for(int i = 0; i < N; i++){ box[0][i] = count; count++; } // douwn for(int j = 1; j < N; j++){ box[j][N-1] = count; count++; } // right to left for(int k = N-2; k >= 0; k--){ box[N-1][k] = count; count++; } // up for(int l = N-2; l >= 1; l--){ box[l][0] = count; count++; } */ while(count <= N*N){ // left to right for(int i = start; i < end; i++){ box[start][i] = count; count++; } // douwn for(int j = start + 1; j < end; j++){ box[j][end-1] = count; count++; } // right to left for(int k = end-2; k >= start; k--){ box[end-1][k] = count; count++; } // up for(int l = end-2; l >= start+1; l--){ box[l][start] = count; count++; } start++; end--; } // check for(int a = 0; a < N; a++){ for(int b = 0; b < N; b++){ if(box[a][b] / 100 == 0){ printf("0"); if(box[a][b] / 10 == 0){ printf("0"); } } printf("%d ",box[a][b]); } printf("\n"); } return 0; }