Identification Division.
Program-Id. rucksack.
author. Robert Sedgewick.
* knapsack problem
* aus Algorithmen p675
Data Division.
Working-Storage Section.
77 i pic 9(4).
77 j pic 9(4).
Linkage Section.
77 cost pic 9(4)V9(2) occurs 1000.
77 val pic 9(4)V9(2) occurs 1000.
77 best pic 9(4)V9(2) occurs 1000.
Procedure Division using cost val best.
perform varying j from 1 until j=n
perform varying i from 1 until i=m
compute te=i-size of j
if te >=0 then
if cost(i) < cost(te)+val(j) then
compute cost(i)=cost(te)+val(j)
compute best(i)=j
end-perform
end-perform
End-Program rucksack.
[Verzeichnis aufwärts0.96unsichere VerbindungÜbersetzung europäischer Sprachen durch Browser2026-11-25]