Order two numerical lists: Difference between revisions
Content added Content deleted
m (ordered the categories to put the sorting algorithms in the proper place.) |
(Order two numerical lists en BASIC256) |
||
Line 549: | Line 549: | ||
list3>=list4 |
list3>=list4 |
||
</pre> |
</pre> |
||
=={{header|BASIC256}}== |
|||
{{trans|FreeBASIC}} |
|||
<lang BASIC256> |
|||
arraybase 1 |
|||
dim list1(5): dim list2(6): dim list3(5): dim list4(5) |
|||
list1 = {1, 2, 1, 5, 2} |
|||
list2 = {1, 2, 1, 5, 2, 2} |
|||
list3 = {1, 2, 3, 4, 5} |
|||
list4 = {1, 2, 3, 4, 5} |
|||
if Orden(list1[], list2[]) then print "list1 < list2" else print "list 1>= list2" |
|||
if Orden(list2[], list3[]) then print "list2 < list3" else print "list2 >= list3" |
|||
if Orden(list3[], list4[]) then print "list3 < list4" else print "list3 >= list4" |
|||
end |
|||
function Orden(listA[], listB[]) |
|||
i = 0 |
|||
l1 = listA[?] |
|||
l2 = listB[?] |
|||
while (listA[i] = listB[i]) and i < l1 and i < l2 |
|||
i = i + 1 |
|||
end while |
|||
if listA[?] < listB[?] then return True |
|||
if listA[?] > listB[?] then return False |
|||
return l1 < l2 |
|||
end function |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
Igual que la entrada de BBC BASIC. |
|||
</pre> |
|||
=={{header|BBC BASIC}}== |
=={{header|BBC BASIC}}== |