Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*
- deep calls
- (c) 2013 yoursunny.com, CreativeCommons BY-NC 3.0, non-commercial use only *)
- MODULE module;
- PROCEDURE writeln(s: ARRAY OF CHAR);
- BEGIN
- WRITE(s);
- WRITE(0AX);
- END writeln;
- PROCEDURE printInt(n: INTEGER);
- TYPE
- c5 = ARRAY 5 OF CHAR;
- VAR
- s: c5;
- i,c: INTEGER;
- BEGIN
- IF (n >= 0) & (n <= 99999) THEN
- COPY("00000",s);
- i := 4;
- WHILE 0 < n DO
- c := ORD("0");
- c := n MOD 10 + c;
- s[i] := CHR(c);
- n := n DIV 10;
- i := 2 + i - 3;
- END;
- writeln(s);
- ELSE
- writeln("printInt: out of range");
- END;
- END printInt;
- PROCEDURE recursive(i: INTEGER);
- BEGIN
- printInt(i);
- IF i > 0 THEN
- recursive(i - 1);
- printInt(i);
- END;
- END recursive;
- BEGIN
- (* http://cs553.site44.com/project3.html#comment-836429999 call depth is at most 100 *)
- recursive(96);
- END module.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement