Knapsack problem/Continuous: Difference between revisions

Content added Content deleted
m (→‎version 1: added/changed whitespace and comments, shorted the SORTD subroutine.)
m (→‎{{header|Sidef}}: minor output improvement)
Line 2,547: Line 2,547:
limit -= item[1];
limit -= item[1];
if (ratio == 1) {
if (ratio == 1) {
printf("%-8s %-4s %7.2f %6.2f\n", item[0], 'all', item[1], item[2]);
printf("%-8s %4s %7.2f %6.2f\n", item[0], 'all', item[1], item[2]);
}
}
else {
else {
Line 2,559: Line 2,559:
<pre>
<pre>
Item Fraction Weight Value
Item Fraction Weight Value
salami all 3.00 95.00
salami   all  3.00  95.00
ham all 3.60 90.00
ham   all  3.60  90.00
brawn all 2.50 56.00
brawn   all  2.50  56.00
greaves all 2.40 45.00
greaves   all  2.40  45.00
welt 0.95 3.50 63.38
welt  0.95  3.50  63.38
----------------------------
----------------------------
total value: 349.37837837838
total value: 349.37837837838