I have created two sorted arrays of size n and m with numeric value in a batch file.
FOR /L %%a IN (0,1,!n!) DO ECHO !vector[%%a]!
FOR /L %%a IN (0,1,!m!) DO ECHO !vector2[%%a]!
This exactly shows the contents of my arrays.
Now I want to write a logic which will print merged sorted array.
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
set i=0
set j=0
set /A totalElements =!n!+!m!
FOR /L %%A IN (1,1,!totalElements!) DO (
if !vector[!i!]! LSS !vector2[!j!]! (
echo "First list"
echo !%vector[!i!]%!
) else (
echo "Second List"
echo !%vector[!i!]%!
)
)
So, this if else
logic is not working. Any idea where in the syntax I have gone wrong? I guess I am not extracting the value from the array correctly?