#include <iostream>
#include <iomanip>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-a))
int foo(int x,int y)
{
int t=max(abs(x),abs(y));
int u=t+t;
int v=u-1;
v=v*v+u;
if(x==-t)
v+=u+t-y;
else if(y==-t)
v+=3*u+x-t;
else if(y==t)
v+=t-x;
else
v+=y-t;
return v;
}
int main()
{
int x,y;
cout<<"\n螺旋队列如下:\n\n";
for(y=-4;y<=4;y++)
{
for(x=-4;x<=4;x++)
cout<<setw(5)<<foo(x,y);
cout<<endl;
}
cout<<endl;
return 0;
}