fortran求解PROGRAM exINTEGER::m(6),i,j,kDO k=1,6,1call sub1(m(k))ENDDOEND PROGRAMSUBROUTINE sub1(n)REAL::xINTEGER::ncall random_seed ()call random_number (x)n=nint(x*100)RETURNEND SUBROUTINE为什么每次得到的m(1)~m(6)都一样?
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/17 12:36:12
fortran求解PROGRAM exINTEGER::m(6),i,j,kDO k=1,6,1call sub1(m(k))ENDDOEND PROGRAMSUBROUTINE sub1(n)REAL::xINTEGER::ncall random_seed ()call random_number (x)n=nint(x*100)RETURNEND SUBROUTINE为什么每次得到的m(1)~m(6)都一样?
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)都一样?
fortran求解PROGRAM exINTEGER::m(6),i,j,kDO k=1,6,1call sub1(m(k))ENDDOEND PROGRAMSUBROUTINE sub1(n)REAL::xINTEGER::ncall random_seed ()call random_number (x)n=nint(x*100)RETURNEND 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 只需调用一次既可