Knapsack problem/Continuous: Difference between revisions

m
→‎{{header|REXX}}: removed superfluous blank lines. -- ~~~~
(Added BBC BASIC)
m (→‎{{header|REXX}}: removed superfluous blank lines. -- ~~~~)
Line 1,434:
=={{header|REXX}}==
Any resemblence to the Fortran code is 120% coincidental.
<lang rexx>/*REXX program to solve the burglar's knapsack (continuous) problem. */
<lang rexx>
/*REXX program to solve the burglar's knapsack (continuous) problem. */
 
@.=''
 
/* name weight value */
@.1='flitch 4 30 '
Line 1,468 ⟶ 1,465:
 
/*sort items by (desending) value per unit weight.*/
 
do j=2 to items
k=j-1; _n=n.j; _w=w.j; _v=v.j
Line 1,501 ⟶ 1,497:
call sy left('total value',nL,'-'), , format(totV,,2)
exit
 
 
/*─────────────────────────────────────one-liner subroutines────────────*/
hdr: indent=left('',5); call verse arg(1); call title; call sep; return
Line 1,510 ⟶ 1,504:
syf: call sy arg(1),format(arg(2),,2),format(arg(3),,2); return
title: call sy center('item',nL),center("weight",wL),center('value',vL); return
verse: say; say; say center(arg(1),40,'─'); say; return</lang>
'''output'''
</lang>
Output:
<pre style="height:30ex;overflow:scroll">
 
Line 1,559 ⟶ 1,552:
total weight--- 15.00
total value--- 349.38
 
</pre>