Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Spiral-matrix/XPL0/spiral-matrix.xpl0
Normal file
22
Task/Spiral-matrix/XPL0/spiral-matrix.xpl0
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue