using namespace std;
int* buildSnailReverse( int* a, int w, int h )
{
int
u[] = { 1, w,-1,-w},
d = w
z = ((d? w: h) - 1 >> 1) * (w + 1) + (~w & d),
n = d? h - w: w - h,
p = 0,
c = n,
i = 0;
while(i
{
a[z] = ++i;
z += u[d];
if (!c--)
{
++d &= 3, c = n ^= p ^= n ^= p;
p++;
}
}
return a;
}
void printArray(int* a, int w, int h)
{
for(int y = 0; y
{
for(int x = 0; x
printf("%3d", a[x + y * w]);
cout <
}
}
int main()
{
int w, h;
cin >> w >> h;
int* a = new int[w * h];
buildSnailReverse(a, w, h);
printArray(a, w, h);
delete[] a;
fflush(stdin);
getchar();
return 0;
}
와
사진으로
이때는 camel 이었군 ㅋㅋㅋㅋ
stdio.h 이거 너무 부끄럽지 않냐?
cmath 모르냐? 앞에다 c붙이는거, cstdio 이런거 모르냐고
알지 바보야 옛날에 예제로 ideone 에서 대충 짜붙인거라 그렇지.
2중 for 열심히 돌렷.