Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
51
Task/Array-concatenation/Action-/array-concatenation.action
Normal file
51
Task/Array-concatenation/Action-/array-concatenation.action
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
BYTE FUNC Concat(INT ARRAY src1,src2,dst BYTE size1,size2)
|
||||
BYTE i
|
||||
|
||||
FOR i=0 TO size1-1
|
||||
DO
|
||||
dst(i)=src1(i)
|
||||
OD
|
||||
FOR i=0 TO size2-1
|
||||
DO
|
||||
dst(size1+i)=src2(i)
|
||||
OD
|
||||
RETURN (size1+size2)
|
||||
|
||||
PROC PrintArray(INT ARRAY a BYTE size)
|
||||
BYTE i
|
||||
|
||||
Put('[)
|
||||
FOR i=0 TO size-1
|
||||
DO
|
||||
PrintI(a(i))
|
||||
IF i<size-1 THEN
|
||||
Put(' )
|
||||
FI
|
||||
OD
|
||||
Put('])
|
||||
RETURN
|
||||
|
||||
PROC Test(INT ARRAY src1,src2 BYTE size1,size2)
|
||||
INT ARRAY res(20)
|
||||
BYTE size
|
||||
|
||||
size=Concat(src1,src2,res,size1,size2)
|
||||
PrintArray(src1,size1)
|
||||
Put('+)
|
||||
PrintArray(src2,size2)
|
||||
Put('=)
|
||||
PrintArray(res,size)
|
||||
PutE() PutE()
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
INT ARRAY
|
||||
a1=[1 2 3 4],
|
||||
a2=[5 6 7 8 9 10],
|
||||
;a workaround for a3=[-1 -2 -3 -4 -5]
|
||||
a3=[65535 65534 65533 65532 65531]
|
||||
|
||||
Test(a1,a2,4,6)
|
||||
Test(a2,a1,6,4)
|
||||
Test(a3,a2,5,4)
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue