fortran循环程序程序错在哪里?program randomimplicit nonedouble precision t,wi,Ptinteger i,mparameter(m=10)do i=1,mreal ::xcall random_seed () call random_number (x) wi=0.1t=-log(x)/wiPt=wi*exp(t*wi)write(*,*) i,t,Ptend doend program random
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 21:28:11
fortran循环程序程序错在哪里?program randomimplicit nonedouble precision t,wi,Ptinteger i,mparameter(m=10)do i=1,mreal ::xcall random_seed () call random_number (x) wi=0.1t=-log(x)/wiPt=wi*exp(t*wi)write(*,*) i,t,Ptend doend program random
fortran循环程序程序错在哪里?
program random
implicit none
double precision t,wi,Pt
integer i,m
parameter(m=10)
do i=1,m
real ::x
call random_seed ()
call random_number (x)
wi=0.1
t=-log(x)/wi
Pt=wi*exp(t*wi)
write(*,*) i,t,Pt
end do
end program random
本来real ::x放do前面可以运行,但是输出的数据相同,求教.补充:我想要许多随机数来看随机数的分布情况
fortran循环程序程序错在哪里?program randomimplicit nonedouble precision t,wi,Ptinteger i,mparameter(m=10)do i=1,mreal ::xcall random_seed () call random_number (x) wi=0.1t=-log(x)/wiPt=wi*exp(t*wi)write(*,*) i,t,Ptend doend program random
call random_seed ()
也必须放到 do 前面去.种子只能种一次.