fortran求解
问题描述:
fortran求解
PROGRAM ex
INTEGER::m(6),i,j,k
DO k=1,6,1
call sub1(m(k))
ENDDO
END PROGRAM
SUBROUTINE sub1(n)
REAL::x
INTEGER::n
call random_seed ()
call random_number (x)
n=nint(x*100)
RETURN
END SUBROUTINE
为什么每次得到的m(1)~m(6)都一样?
答
PROGRAM ex
INTEGER::m(6),i,j,k
call random_seed ()
DO k=1,6,1
call sub1(m(k))
ENDDO
END PROGRAM
SUBROUTINE sub1(n)
REAL::x
INTEGER::n
call random_number (x)
n=nint(x*100)
write(*,*) n
RETURN
END SUBROUTINE
random_seed 只需调用一次既可