Jump to content

Knapsack problem/Continuous: Difference between revisions

→‎{{header|C++}}: Added output the lack of which had been previously flagged up.
(Scala contribution added.)
(→‎{{header|C++}}: Added output the lack of which had been previously flagged up.)
Line 498:
 
=={{header|C++}}==
{{output?|C++|reason}}
<lang cpp>#include<iostream>
#include<algorithm>
Line 594 ⟶ 593:
return 0;
}</lang>
 
{{out}}
<pre>
Total Value = 349.378
Total Weight = 15
Items Used:
We took 3kg of "salami" and the value it brought is 95
We took 3.6kg of "ham" and the value it brought is 90
We took 2.5kg of "brawn" and the value it brought is 56
We took 2.4kg of "greaves" and the value it brought is 45
We took 3.5kg of "welt" and the value it brought is 63.3784
</pre>
 
===Alternate Version===
Line 649 ⟶ 660:
}
}</lang>
 
{{out}}
<pre>
Take all salami
Take all ham
Take all brawn
Take all greaves
Take 3.5kg of welt
</pre>
 
=={{header|Common Lisp}}==
9,486

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.