tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
26
Task/Pascals-triangle/Fortran/pascals-triangle.f
Normal file
26
Task/Pascals-triangle/Fortran/pascals-triangle.f
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
PROGRAM Pascals_Triangle
|
||||
|
||||
CALL Print_Triangle(8)
|
||||
|
||||
END PROGRAM Pascals_Triangle
|
||||
|
||||
SUBROUTINE Print_Triangle(n)
|
||||
|
||||
IMPLICIT NONE
|
||||
INTEGER, INTENT(IN) :: n
|
||||
INTEGER :: c, i, j, k, spaces
|
||||
|
||||
DO i = 0, n-1
|
||||
c = 1
|
||||
spaces = 3 * (n - 1 - i)
|
||||
DO j = 1, spaces
|
||||
WRITE(*,"(A)", ADVANCE="NO") " "
|
||||
END DO
|
||||
DO k = 0, i
|
||||
WRITE(*,"(I6)", ADVANCE="NO") c
|
||||
c = c * (i - k) / (k + 1)
|
||||
END DO
|
||||
WRITE(*,*)
|
||||
END DO
|
||||
|
||||
END SUBROUTINE Print_Triangle
|
||||
Loading…
Add table
Add a link
Reference in a new issue