2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
24
Task/Multiplication-tables/Fortran/multiplication-tables-4.f
Normal file
24
Task/Multiplication-tables/Fortran/multiplication-tables-4.f
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
PROGRAM TABLES
|
||||
IMPLICIT NONE
|
||||
C
|
||||
C Produce a formatted multiplication table of the kind memorised by rote
|
||||
C when in primary school. Only print the top half triangle of products.
|
||||
C
|
||||
C 23 Nov 15 - 0.1 - Adapted from original for VAX FORTRAN - MEJT
|
||||
C
|
||||
INTEGER I,J,K ! Counters.
|
||||
CHARACTER*32 S ! Buffer for format specifier.
|
||||
C
|
||||
K=12
|
||||
C
|
||||
WRITE(S,1) K,K
|
||||
1 FORMAT(8H(4H0 |,,I2.2,11HI4,/,4H --+,I2.2,9H(4H----)))
|
||||
WRITE(6,S) (I,I = 1,K) ! Print heading.
|
||||
C
|
||||
DO 3 I=1,K ! Step down the lines.
|
||||
WRITE(S,2) (I-1)*4+1,K ! Update format string.
|
||||
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) ! Use format to print row with leading blanks, unused fields are ignored.
|
||||
3 CONTINUE
|
||||
C
|
||||
END
|
||||
35
Task/Multiplication-tables/Fortran/multiplication-tables-5.f
Normal file
35
Task/Multiplication-tables/Fortran/multiplication-tables-5.f
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
PROGRAM TABLES
|
||||
C
|
||||
C Produce a formatted multiplication table of the kind memorised by rote
|
||||
C when in primary school. Only print the top half triangle of products.
|
||||
C
|
||||
C 23 Nov 15 - 0.1 - Adapted from original for VAX FORTRAN - MEJT
|
||||
C 24 Nov 15 - 0.2 - FORTRAN IV version adapted from VAX FORTRAN and
|
||||
C compiled using Microsoft FORTRAN-80 - MEJT
|
||||
C
|
||||
DIMENSION K(12)
|
||||
DIMENSION A(6)
|
||||
DIMENSION L(12)
|
||||
C
|
||||
COMMON //A
|
||||
EQUIVALENCE (A(1),L(1))
|
||||
C
|
||||
DATA A/'(1H ',',I2,','1H|,','01X,','I3,1','2I4)'/
|
||||
C
|
||||
WRITE(1,1) (I,I=1,12)
|
||||
1 FORMAT(4H0 |,12I4,/,4H --+12(4H----))
|
||||
C
|
||||
C Overlaying the format specifier with an integer array makes it possibe
|
||||
C to modify the number of blank spaces. The number of blank spaces is
|
||||
C stored as two consecuitive ASCII characters that overlay on the
|
||||
C integer value in L(7) in the ordr low byte, high byte.
|
||||
C
|
||||
DO 3 I=1,12
|
||||
L(7)=(48+(I*4-3)-((I*4-3)/10)*10)*256+48+((I*4-3)/10)
|
||||
DO 2 J=1,12
|
||||
K(J)=I*J
|
||||
2 CONTINUE
|
||||
WRITE(1,A)I,(K(J), J = I,12)
|
||||
3 CONTINUE
|
||||
C
|
||||
END
|
||||
33
Task/Multiplication-tables/Fortran/multiplication-tables-6.f
Normal file
33
Task/Multiplication-tables/Fortran/multiplication-tables-6.f
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
PROGRAM TABLES
|
||||
C
|
||||
C Produce a formatted multiplication table of the kind memorised by rote
|
||||
C when in primary school. Only print the top half triangle of products.
|
||||
C
|
||||
C 23 Nov 15 - 0.1 - Adapted from original for VAX FORTRAN - MEJT
|
||||
C 24 Nov 15 - 0.2 - FORTRAN IV version adapted from VAX FORTRAN and
|
||||
C compiled using Microsoft FORTRAN-80 - MEJT
|
||||
C 25 Nov 15 - 0.3 - Microsoft FORTRAN-80 version using a BYTE array
|
||||
C which makes it easier to understand what is going
|
||||
C on. - MEJT
|
||||
C
|
||||
BYTE A
|
||||
DIMENSION A(24)
|
||||
DIMENSION K(12)
|
||||
C
|
||||
DATA A/'(','1','H',' ',',','I','2',',','1','H','|',',',
|
||||
+ '0','1','X',',','I','3',',','1','1','I','4',')'/
|
||||
C
|
||||
C Print a heading and (try to) underline it.
|
||||
C
|
||||
WRITE(1,1) (I,I=1,12)
|
||||
1 FORMAT(4H |,12I4,/,4H --+12(4H----))
|
||||
DO 3 I=1,12
|
||||
A(13)=48+((I*4-3)/10)
|
||||
A(14)=48+(I*4-3)-((I*4-3)/10)*10
|
||||
DO 2 J=1,12
|
||||
K(J)=I*J
|
||||
2 CONTINUE
|
||||
WRITE(1,A)I,(K(J), J = I,12)
|
||||
3 CONTINUE
|
||||
C
|
||||
END
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
WRITE(1,4) (A(J), J = 1,24)
|
||||
4 FORMAT(1x,24A1)
|
||||
14
Task/Multiplication-tables/Fortran/multiplication-tables-8.f
Normal file
14
Task/Multiplication-tables/Fortran/multiplication-tables-8.f
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
| 1 2 3 4 5 6 7 8 9 10 11 12
|
||||
--+------------------------------------------------
|
||||
1| 1 2 3 4 5 6 7 8 9 10 11 12
|
||||
2| 4 6 8 10 12 14 16 18 20 22 24
|
||||
3| 9 12 15 18 21 24 27 30 33 36
|
||||
4| 16 20 24 28 32 36 40 44 48
|
||||
5| 25 30 35 40 45 50 55 60
|
||||
6| 36 42 48 54 60 66 72
|
||||
7| 49 56 63 70 77 84
|
||||
8| 64 72 80 88 96
|
||||
9| 81 90 99 108
|
||||
10| 100 110 120
|
||||
11| 121 132
|
||||
12| 144
|
||||
Loading…
Add table
Add a link
Reference in a new issue