Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
28
Task/Filter/XPL0/filter.xpl0
Normal file
28
Task/Filter/XPL0/filter.xpl0
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
|
||||
proc Filter(A, B, Option); \Select all even numbers from array A
|
||||
int A, B, Option; \ and return them in B, unless Option = true
|
||||
int I, J;
|
||||
[J:= 0;
|
||||
for I:= 1 to A(0) do
|
||||
if (A(I)&1) = 0 then
|
||||
[J:= J+1;
|
||||
if Option then
|
||||
A(J):= A(I)
|
||||
else B(J):= A(I);
|
||||
];
|
||||
if Option then A(0):= J else B(0):= J;
|
||||
];
|
||||
|
||||
int Array, Evens(11), I;
|
||||
[Array:= [10, 3, 1, 4, 1, 5, 9, 2, 6, 5, 4];
|
||||
Filter(Array, Evens, false);
|
||||
for I:= 1 to Evens(0) do
|
||||
[IntOut(0, Evens(I)); ChOut(0, ^ )];
|
||||
CrLf(0);
|
||||
|
||||
Filter(Array, Evens \not used\, true);
|
||||
for I:= 1 to Array(0) do
|
||||
[IntOut(0, Array(I)); ChOut(0, ^ )];
|
||||
CrLf(0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue