#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int row, col;
int n = 5;
int magic[5][5];
for(int r=0 ; r<n ; r++)
{
for(int c=0 ; c<n ; c++)
{
magic[r][c] = 0;
}
}
row = 1;
col = (n+1)/2;
magic[row - 1][col - 1]=1;
for(int i=2 ; i<=(n*n) ; i++)
{
row-=1;
col-=1;
if(row==0 && col==0)
{
col++; row+=2;
}
else if(row==0) row=n;
else if(col==0) col=n;
else if(magic[row - 1][col - 1]!=0)
{
col++; row+=2;
}
magic[row - 1][col - 1]=i;
}
for(int Row=4; Row>-1 ; Row--)
{
for(int Col=4; Col>-1 ; Col--)
{
cout << setw (5) << magic[Row][Col];
}
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewoKaW50IHJvdywgY29sOwppbnQgbiA9IDU7CmludCBtYWdpY1s1XVs1XTsKCgoKZm9yKGludCByPTAgOyByPG4gOyByKyspCgp7CmZvcihpbnQgYz0wIDsgYzxuIDsgYysrKQoKewoKbWFnaWNbcl1bY10gPSAwOwoKfQoKfQoKCnJvdyA9IDE7Cgpjb2wgPSAobisxKS8yOwoKbWFnaWNbcm93IC0gMV1bY29sIC0gMV09MTsKCgoKZm9yKGludCBpPTIgOyBpPD0obipuKSA7IGkrKykKCnsKCnJvdy09MTsKCmNvbC09MTsKCmlmKHJvdz09MCAmJiBjb2w9PTApCnsKCmNvbCsrOyByb3crPTI7Cgp9CgplbHNlIGlmKHJvdz09MCkgcm93PW47CgplbHNlIGlmKGNvbD09MCkgY29sPW47CgplbHNlIGlmKG1hZ2ljW3JvdyAtIDFdW2NvbCAtIDFdIT0wKQoKewoKY29sKys7IHJvdys9MjsKCn0KCgptYWdpY1tyb3cgLSAxXVtjb2wgLSAxXT1pOwoKfQoKCmZvcihpbnQgUm93PTQ7IFJvdz4tMSA7IFJvdy0tKQoKewoKZm9yKGludCBDb2w9NDsgQ29sPi0xIDsgQ29sLS0pCgp7Cgpjb3V0IDw8IHNldHcgKDUpIDw8IG1hZ2ljW1Jvd11bQ29sXTsKCn0KCmNvdXQ8PGVuZGw7Cgp9CgpyZXR1cm4gMDsKCn0=