Sei sulla pagina 1di 1

implicit real*8(a-h,o-z) implicit integer*8(i-n) include 'param.cmn' dimension num(maxel),ihcom(kci),nto2(30) TYPE :: Node integer :: nnum !

introduce character or a variable (integer or r eal) here. TYPE(Node), POINTER :: next ! pointer here. -- In a node there are two boxes. one for data (derived above) and another for pointer. END TYPE Node TYPE(Node), POINTER :: nhead, new !! Initially empty list ! this is a node consists of two boxes. open(unit=1,file='mat.inp') read(1,*)(num(i),i=1,6) write(*,*)(num(i),i=1,6) allocate (nhead) nhead%nnum=num(1) nullify(nhead%next) write(*,*)'nhead%nnum',nhead%nnum do i=2,6 allocate(new) new%nnum=num(i) new%next => nhead nhead => new write(*,*)'new%nnum',new%nnum write(*,*) enddo nullify(new) new =>nhead do i=1,6 write(*,*)'new%nnum',new%nnum new => new%Next enddo DO WHILE (ASSOCIATED(new)) PRINT *, new%nnum new => new%Next END DO stop end

! link previous element to "i"th ele ! making "i"th element as a 'head'.

ment

c c c c

Potrebbero piacerti anche