Multiplication tables: Difference between revisions
Content deleted Content added
Line 1,765: | Line 1,765: | ||
===VAX FORTRAN=== |
===VAX FORTRAN=== |
||
<lang Fortran> |
<lang Fortran> |
||
PROGRAM TIMES |
PROGRAM TIMES |
||
IMPLICIT NONE |
IMPLICIT NONE |
||
C |
C |
||
Line 1,771: | Line 1,771: | ||
C when in primary school. Only print the top half triangle of products. |
C when in primary school. Only print the top half triangle of products. |
||
C |
C |
||
C 23 Nov 15 - 0.1 - Adapted from original for VAX FORTRAN - MEJT |
|||
INTEGER I,J,K |
|||
C |
|||
CHARACTER*32 S |
|||
INTEGER I,J,K ! Counters. |
|||
CHARACTER*32 S ! Buffer for format specifier. |
|||
C |
C |
||
K=12 |
K=12 |
||
Line 1,778: | Line 1,780: | ||
WRITE(S,1) K,K |
WRITE(S,1) K,K |
||
1 FORMAT(8H(4H0 |,,I2.2,11HI4,/,4H --+,I2.2,9H(4H----))) |
1 FORMAT(8H(4H0 |,,I2.2,11HI4,/,4H --+,I2.2,9H(4H----))) |
||
WRITE(6,S) (I,I = 1,K) |
WRITE(6,S) (I,I = 1,K) ! Print heading. |
||
C |
|||
DO 3 I=1,K |
|||
DO 3 I=1,K ! Step down the lines. |
|||
WRITE(S,2) (I-1)*4+1,K |
|||
WRITE(S,2) (I-1)*4+1,K ! Update format string. |
|||
2 FORMAT(8H(I3,1H|,,I2.2,5HX,I3,,I2.2,3HI4),12X) |
|||
2 FORMAT(12H(1H ,I2,1H|,,I2.2,5HX,I3,,I2.2,3HI4),8X) ! Format string includes an explicit carridge control character. |
|||
WRITE(6,S) I,(I*J, J = I,K) |
|||
WRITE(6,S) I,(I*J, J = I,K) ! Use format to print row with leading blanks, unused fields are ignored. |
|||
3 CONTINUE |
3 CONTINUE |
||
C |
C |
||
END |
END |
||
</lang>Based on the above code but with a slight modification as VAX FORTRAN doesn't allow zero width fields in a format statement. |
</lang>Based on the above code but with a slight modification as VAX FORTRAN doesn't allow zero width fields in a format statement. The number of rows and columns can also be altered by modifying the value of K which must be in the range 1 - 25. |
||
=={{header|Go}}== |
=={{header|Go}}== |
||
<lang go> |
<lang go> |