Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Cobol/verschiedene-Autoren/Wirth/   (verschiedene Autoren Version 0.7©)  Datei vom 4.1.2008 mit Größe 1 kB image not shown  

Quelle  ggt.cob   Sprache: Cobol

 

          identification division.
       program-id. ggt.
      *  aus Wirth, systematisches Programmieren p. 46 
       author. "JD".
       date-written. 11.9.2005.
       date-compiled.
       data division.
       working-storage section.
       77 a pic 9(4).
       77 c pic 9(4).
       77 u pic 9(4).
       77 b pic 9(4).
       77 d pic 9(4).
       77 v pic 9(4).
       77 q pic 9(4).
       77 t pic 9(4).
       linkage section.
       77 x   pic 9(4).
       77 y   pic 9(4).
       77 r   pic 9(4).
       procedure division using x y r.
      * computes ggt(x,y)
         move x to a.
         move 0 to c
         move 1 to u.
         move y to b.
         move 1 to d.
         move 0 to v.
         divide a by b giving q
         compute r = function mod(a, b)
      * invariant a =  q * b + r   
         perform until r = 0
      *   ggt(x,y) = c*x + d*y    
           move b to a
           move r to b
           move u to t
           move c to u
           compute c = t - q * c
           move v to t
           move d to v
           compute d = t - q * d
           divide a by b giving q
           compute r = function mod(a, b)
         end-perform.
      *  rules
      * ggt(2*m,2*n) = 2 * ggt(m,n)
      * etc.
        end-program ggt.

Messung
CHZG
9110010096

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*Bot Zugriff