fortran中运行结果为NaN是什么意思
imensionx(4),y(4)doubleprecisionx,y,t,zdatax/0.0,2.5,0.0,2.5/datay/90.0,90.0,88.0,88....
imension x(4),y(4)
double precision x,y,t,z
data x/0.0,2.5,0.0,2.5/
data y/90.0,90.0,88.0,88.0/
write(*,*)"please enter t"
read(*,*) t
call enlgr(x,y,4,t,z)
write(*,20) t,z
20 format(1x,'t=',f6.3,10x,'z=',d15.6)
end
subroutine enlgr(x,y,n,t,z)
dimension x(n),y(n)
double precision x,y,t,z,s
z=0.0
if (n.LE.0) return
if (n.EQ.1) then
z=y(1)
return
end if
if (N.EQ.2) then
z=(y(1)*(t-x(2))-y(2)*(t-x(1)))/(x(1)-x(2))
return
end if
i=1
10 if (x(i).LT.t) then
i=i+1
if (i.LE.n) goto 10
end if
k=i-4
if(k.LT.1) k=1
m=i+3
if(m.GT.n) m=n
do 30 i=k,m
s=1.0
do 20 j=k,m
if (j.NE.i) then
s=s*(t-x(j))/(x(i)-x(j))
end if
20 continue
z=z+s*y(i)
30 continue
return
end 展开
double precision x,y,t,z
data x/0.0,2.5,0.0,2.5/
data y/90.0,90.0,88.0,88.0/
write(*,*)"please enter t"
read(*,*) t
call enlgr(x,y,4,t,z)
write(*,20) t,z
20 format(1x,'t=',f6.3,10x,'z=',d15.6)
end
subroutine enlgr(x,y,n,t,z)
dimension x(n),y(n)
double precision x,y,t,z,s
z=0.0
if (n.LE.0) return
if (n.EQ.1) then
z=y(1)
return
end if
if (N.EQ.2) then
z=(y(1)*(t-x(2))-y(2)*(t-x(1)))/(x(1)-x(2))
return
end if
i=1
10 if (x(i).LT.t) then
i=i+1
if (i.LE.n) goto 10
end if
k=i-4
if(k.LT.1) k=1
m=i+3
if(m.GT.n) m=n
do 30 i=k,m
s=1.0
do 20 j=k,m
if (j.NE.i) then
s=s*(t-x(j))/(x(i)-x(j))
end if
20 continue
z=z+s*y(i)
30 continue
return
end 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询