Anonymous user
Knapsack problem/Continuous: Difference between revisions
→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
Catskill549 (talk | contribs) |
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
||
Line 1,869:
=={{header|Kotlin}}==
<lang scala>// version 1.1.
data class Item(val name: String, val weight: Double, val value: Double)
Line 1,882:
Item("welt", 3.7, 67.0),
Item("salami", 3.0, 95.0),
Item("sausage", 5.9, 98.0)
)
Line 1,900:
sumValue += item.value
print("${item.name.padEnd(11)} ${"%3.1f".format(item.weight)} ${"%5.2f".format(item.value)}")
println(" 100.00")
}
else {
|