Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Delphi/Elbe 1.0/Sources/     Datei vom 1.10.2010 mit Größe 13 kB image not shown  

Quelle  rucksack.cob   Sprache: Cobol

 

       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.  

Messung
CHZG
869710094

¤ Dauer der Verarbeitung: 0.5 Sekunden  (vorverarbeitet am  2026-11-25) ¤

*© Formatika GbR, Deutschland