[Fortran] 纯文本查看 复制代码
function P(n) result(Pa)
implicit none
integer::i
integer,intent(in)::n
real::a(1827),b(1827),c(1827),d(1827),e(1827),Pa
open(1,file='et.csv')
read(1,*)
do i=1,1827
read(1,*)a(i),b(i),c(i),d(i),e(i)
enddo
close(1)
Pa=a(n)
end function
function ET(n) result(ETa)
implicit none
integer::z
integer,intent(in)::n
real::a(1827),b(1827),c(1827),d(1827),e(1827),ETa
open(1,file='et.csv')
read(1,*)
do z=1,1827
read(1,*)a(z),b(z),c(z),d(z),e(z)
enddo
close(1)
ETa=a(n)
end function
recursive function th(n) result(tha)
implicit none
real::tha,n,thmax,P,ET
if(n==1)then
tha=thmax
else
tha=th(n-1)+P(n-1)-ET(n-1)
endif
if(tha>thmax) tha=thmax
end function
program main
implicit none
integer::n,th
print*,'input n'
read*,n
print*,th(n)
end program main