1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
program main
      call pyramid(1)
      write(*,*)
      call pyramid(2)
      write(*,*)
      call pyramid(3)
      write(*,*)
      call pyramid(4)
      write(*,*)
      call pyramid(5)
      end

      subroutine pyramid(height)
      integer width, height, w
      w = (height - 1)
      width = w * 2 + 1
      do i = 1, height
         call draw(' ', w - i + 1)
         call draw('*', i - 1)
         write(*, '(a$)') '*'
         call draw('*', i - 1)
         call draw(' ', w - i + 1)
         write(*,*)
      end do
      end

      subroutine draw(c, count)
      character c
      integer count
      do i=1, count
         write(*, '(a$)') c
      end do
      end