[Fortran] 纯文本查看 复制代码 program mytp16
implicit none
integer n
double precision x,poly
double precision,allocatable::cf(:),npoly(:)
write(6,*)'input the nombre n'
read(5,*)n
write(6,*)'input the x'
read(5,*)x
allocate(cf(0:n),npoly(n))
cf=poly(n,npoly,cf,x)
npoly=poly(n,npoly,cf,x)
write(6,'("npoly(",i3,")=",d15.8)')n,npoly(n)
end program
double precision function poly(n,npoly,cf,x)
implicit none
integer i,n
double precision cf(0:n),npoly(0:n),x
open(15,file='the coefficient of npoly.txt')
do i=0,n
cf(i)=2.d0*i+1
write(15,*) cf(i)
end do
close(15)
open(15,file='the coefficient of npoly.txt')
do i=0,n
read(15,*) cf(i)
write(6,'("cf(",i3,")=",d15.8)')i,cf(i)
end do
close(15)
npoly(0)=cf(n)
npoly(1)=cf(n)*x+cf(n-1)
do i=2,n
npoly(i)=npoly(i-1)*x+cf(n-i)
end do
poly=npoly(n)
end function poly
! --------------------------------------------------
! Silverfrost FTN95 for Microsoft Visual Studio
! Free Format FTN95 Source File
! --------------------------------------------------
|