#include <iostream> #include <iomanip> #include <cstring> using namespace std; const int N = 105; int a[N][N]; int main() { int n, x, y,count; cin>> n; memset(a,0,sizeof(a)); count=a[x=0][y=n-1]=1; while (count<n*n) { while (x+1<n && !a[x+1][y]) a[++x][y]= ++count; while (y-1>=0&&!a[x][y- 1]) a[x][--y]= ++count; while (x-1>=0&&!a[x-1][y]) a[--x][y]= ++count; while (y+1<n &&!a[x][y+1]) a[x][++y]= ++count; } for (x=0; x<n; x++) { for (y=0; y<n; y++) { cout<<setw(5)<<a[x][y]; } cout<<endl; } return 0; }