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.
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
|
Haftungshinweis
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.
|