identification division.
program-id. succ.
* aus Herold/Lutz/Wohlrab
* Grundlagen der Informatik
* p. 629
author. JD.
date-written. 3.11.2008.
date-compiled.
data division.
linkage section.
77 x pic 9(8).
77 r pic 9(8).
procedure division using x returning r.
add 1 to x giving r.
end-program succ.
identification division.
program-id. pred.
data division.
linkage section.
77 x pic 9(8).
77 r pic 9(8).
procedure division using x returning r.
if x=0 move 0 to r else subtract 1 from x giving r.
end-program pred.
identification division.
program-id. adder.
* dito
data division.
linkage section.
77 x pic 9(8).
77 y pic 9(8).
77 r pic 9(8).
procedure division using x y returning r.
if x=0 move y to r
else
compute r=function succ (function adder(function pred(x),y)).
end-program adder.
identification division.
program-id. mult.
* dito
data division.
linkage section.
77 x pic 9(8).
77 y pic 9(8).
77 r pic 9(8).
procedure division using x y returning r.
if x=0 move 0 to r
else
compute r=function adder(function mult(function pred(x),y))
end-program mult.
identification division.
program-id. main.
* dito
data division.
working-storage section.
77 x pic 9(8).
77 y pic 9(8).
77 r pic 9(8).
procedure division using x y returning r.
display "Gib zwei Zahlen durch Kommata getrennt ein:"
accept x
accept y
move function adder(x,y) to r
display "Add("x","y")="r
move function mult(x,y) to r
display "mult("x","y")="r
end-program main.
¤ Dauer der Verarbeitung: 0.3 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.
|