Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
19
Task/Multiplication-tables/Fortran/multiplication-tables-1.f
Normal file
19
Task/Multiplication-tables/Fortran/multiplication-tables-1.f
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
program multtable
|
||||
implicit none
|
||||
|
||||
integer :: i, j, k
|
||||
|
||||
write(*, "(a)") " x| 1 2 3 4 5 6 7 8 9 10 11 12"
|
||||
write(*, "(a)") "--+------------------------------------------------"
|
||||
do i = 1, 12
|
||||
write(*, "(i2, a)", advance="no") i, "|"
|
||||
do k = 2, i
|
||||
write(*, "(a4)", advance="no") ""
|
||||
end do
|
||||
do j = i, 12
|
||||
write(*, "(i4)", advance="no") i*j
|
||||
end do
|
||||
write(*, *)
|
||||
end do
|
||||
|
||||
end program multtable
|
||||
11
Task/Multiplication-tables/Fortran/multiplication-tables-2.f
Normal file
11
Task/Multiplication-tables/Fortran/multiplication-tables-2.f
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Cast forth a twelve times table, suitable for chanting at school.
|
||||
INTEGER I,J !Steppers.
|
||||
CHARACTER*52 ALINE !Scratchpad.
|
||||
WRITE(6,1) (I,I = 1,12) !Present the heading.
|
||||
1 FORMAT (" ×|",12I4,/," --+",12("----")) !Alas, can't do overprinting with underlines now.
|
||||
DO 3 I = 1,12 !Step down the lines.
|
||||
WRITE (ALINE,2) I,(I*J, J = 1,12) !Prepare one line.
|
||||
2 FORMAT (I3,"|",12I4) !Aligned with the heading.
|
||||
ALINE(5:1 + 4*I) = "" !Scrub the unwanted part.
|
||||
3 WRITE (6,"(A)") ALINE !Print the text.
|
||||
END !"One one is one! One two is two! One three is three!...
|
||||
10
Task/Multiplication-tables/Fortran/multiplication-tables-3.f
Normal file
10
Task/Multiplication-tables/Fortran/multiplication-tables-3.f
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Cast forth a twelve times table, suitable for chanting at school.
|
||||
INTEGER I,J !Steppers.
|
||||
CHARACTER*16 FORMAT !Scratchpad.
|
||||
WRITE(6,1) (I,I = 1,12) !Present the heading.
|
||||
1 FORMAT (" ×|",12I4,/," --+",12("----")) !Alas, can't do overprinting with underlines now.
|
||||
DO 3 I = 1,12 !Step down the lines.
|
||||
WRITE (FORMAT,2) (I - 1)*4,13 - I !Spacing for omitted fields, count of wanted fields.
|
||||
2 FORMAT ("(I3,'|',",I0,"X,",I0,"I4)") !The format of the FORMAT statement.
|
||||
3 WRITE (6,FORMAT) I,(I*J, J = I,12) !Use it.
|
||||
END !"One one is one! One two is two! One three is three!...
|
||||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue