Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-06 - 43,50417/ack3.pas
There are no other files named ack3.pas in the archive.
00010	  PROGRAM ACK3;
00020	VAR
00030	  STACK:ARRAY[1..1000] OF INTEGER;
00040	  X,Y,STACK_COUNT,TIME,A:INTEGER;
00050	
00060	  PROCEDURE PUSH(K:INTEGER);
00070	   BEGIN
00080	    STACK_COUNT:=STACK_COUNT+1;
00090	    STACK[STACK_COUNT]:=K;
00100	   END (* OF PUSH *);
00110	
00120	  PROCEDURE POP(VAR K:INTEGER);
00130	   BEGIN
00140	    K:=STACK[STACK_COUNT];
00150	    STACK_COUNT:=STACK_COUNT-1;
00160	   END (* OF POP *);
00170	
00180	  FUNCTION ACKER(X,Y:INTEGER):INTEGER;
00190	  CONST
00200	    STACKEND=-1;
00210	   BEGIN
00220	    STACK_COUNT:=0;
00230	    PUSH(STACKEND);
00240	     REPEAT
00250	      IF X=0
00260	      THEN
00270	       BEGIN
00280	        POP(X); Y:=Y+1
00290	       END
00300	      ELSE
00310	       IF Y=0
00320	       THEN
00330	         BEGIN
00340	          Y:=1; X:=X-1
00350	         END
00360	       ELSE
00370	         BEGIN
00380	          PUSH(X-1); Y:=Y-1
00390	         END;
00400	     UNTIL X=STACKEND;
00410	    ACKER:=Y
00420	   END (* OF ACKER *);
00430	  (* HAUPTPROGRAMM *)
00440	
00450	 BEGIN
00460	WHILE TRUE DO BEGIN
00470	  WRITE(TTY,'X:');BREAK;
00480	  READ(TTY,X);
00490	  WRITE(TTY,'Y:'); BREAK;
00500	  READ(TTY,Y);
00510	  TIME:=CLOCK;
00520	  A:=ACKER(X,Y);
00530	  TIME:=CLOCK-TIME;
00540	  WRITELN(TTY,'  ACKERMANN(',X:2,',',Y:2,')=',A:4);
00550	  WRITELN(TTY,'    CPU-ZEIT=',TIME:6);
00560	END
00570	 END.
00580	(* OF PROGRAM *)