C Illustrates array trickery C Created: Joe Zachary, November 15, 1992 C Modified: PROGRAM TABLE3 IMPLICIT NONE INTEGER ROW, COL, TABLES(9,9,3) C First we create the addition table DO ROW = 1, 9 DO COL = 1, 9 TABLES(ROW,COL,1) = ROW+COL ENDDO ENDDO C Next we create the subtraction table DO ROW = 1, 9 DO COL = 1, 9 TABLES(ROW,COL,2) = ROW-COL ENDDO ENDDO C Finally we create the multiplication table DO ROW = 1, 9 DO COL = 1, 9 TABLES(ROW,COL,3) = ROW*COL ENDDO ENDDO C Now we print out the addition table PRINT *, 'The addition table' PRINT * CALL PTABLE(TABLES) STOP END C Here's a subroutine to print out an arithmetic table. Notice that C the subroutine expects a 9x9 array as its only argument. SUBROUTINE PTABLE(TABLE) IMPLICIT NONE INTEGER TABLE(9,9) INTEGER ROW, COL PRINT *, ' 1 2 3 4 5 6 7 8 9' PRINT *, ' +---------------------------' DO ROW = 1, 9 WRITE (UNIT=*, FMT=100) ROW, (TABLE(ROW,COL), COL=1,9) ENDDO 100 FORMAT (I2,' |', 9I3) END