Knapsack problem/Continuous: Difference between revisions

Content added Content deleted
m (→‎version 1: added comments, added a variable to specify number of decimal digits in the FORMAT for SAY, removed an unnecessary subroutine, allowed the specification of weight and output precision.)
m (→‎version 1: typo)
Line 1,945: Line 1,945:
call show 'unsorted item list' /*display a header and the @ list*/
call show 'unsorted item list' /*display a header and the @ list*/
/*for short lists, method is ok. */
/*for short lists, method is ok. */
do sorts=2 to items /*sort by desending value/unit wt*/
do sorts=2 to items /*sort by descending value/unit wt*/
_n=n.sorts; _w=w.sorts; _v=v.sorts /*calc. placeholders for DO loop.*/
_n=n.sorts; _w=w.sorts; _v=v.sorts /*calc. placeholders for DO loop.*/
do k=sorts-1 by -1 to 1 while v.k/w.k < _v/_w /*order it*/
do k=sorts-1 by -1 to 1 while v.k/w.k < _v/_w /*order it*/