Order two numerical lists: Difference between revisions
Content added Content deleted
(Order two numerical lists en BASIC256) |
(Order two numerical lists en Yabasic) |
||
Line 2,276: | Line 2,276: | ||
list[6] < list[7] -> true |
list[6] < list[7] -> true |
||
</pre> |
</pre> |
||
=={{header|Yabasic}}== |
|||
{{trans|FreeBASIC}} |
|||
<lang yabasic> |
|||
read num : dim list1(4) |
|||
read num : dim list2(5) |
|||
read num : dim list3(4) |
|||
read num : dim list4(4) |
|||
if Orden(list1(), list2()) then print "list1 < list2" else print "list1 >= list2" : fi |
|||
if Orden(list2(), list3()) then print "list2 < list3" else print "list2 >= list3" : fi |
|||
if Orden(list3(), list4()) then print "list3 < list4" else print "list3 >= list4" : fi |
|||
end |
|||
sub Orden(listA(), listB()) |
|||
i = 0 |
|||
l1 = arraysize(listA(), 1) |
|||
l2 = arraysize(listB(), 1) |
|||
while listA(i) = listB(i) and i < l1 and i < l2 |
|||
i = i + 1 |
|||
wend |
|||
if listA(i) < listB(i) then return True : fi |
|||
if listA(i) > listB(i) then return False : fi |
|||
return l1 < l2 |
|||
end sub |
|||
data 1, 2, 1, 5, 2 |
|||
data 1, 2, 1, 5, 2, 2 |
|||
data 1, 2, 3, 4, 5 |
|||
data 1, 2, 3, 4, 5 |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
Igual que la entrada de BBC BASIC. |
|||
</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |