22 lines
543 B
Text
22 lines
543 B
Text
def N=5;
|
|
int A(N,N);
|
|
int I, J, X, Y, Steps, Dir;
|
|
include c:\cxpl\codes;
|
|
[Clear;
|
|
I:= 0; X:= -1; Y:= 0; Steps:= N; Dir:= 0;
|
|
repeat for J:= 1 to Steps do
|
|
[case Dir&3 of
|
|
0: X:= X+1;
|
|
1: Y:= Y+1;
|
|
2: X:= X-1;
|
|
3: Y:= Y-1
|
|
other [];
|
|
A(X,Y):= I;
|
|
Cursor(X*3,Y); IntOut(0,I);
|
|
I:= I+1;
|
|
];
|
|
Dir:= Dir+1;
|
|
if Dir&1 then Steps:= Steps-1;
|
|
until Steps = 0;
|
|
Cursor(0,N);
|
|
]
|