排了排版,差不多了解了。除了那个 txt 文件之外。
这可能是你想要的代码
[Fortran] 纯文本查看 复制代码 Program www_fcode_cn
Implicit None
Integer , parameter :: KI = SELECTED_INT_KIND(10)
write(*,*) fp( 1234567890_ki ) , fq( 1234567890_ki )
contains
Integer(Kind=KI) Function fp( n )
Integer(Kind=KI) :: n
integer(Kind=KI) :: t
integer :: k , i
integer , allocatable :: c(:)
t = n
k = 1
do
if ( t < 10 ) exit
t = t/10
k = k + 1
end do
allocate( c(k) )
t = n
do i = 1 , k
c(i) = mod( t , 10 )
t = t/10
end do
t = 0
do i = 1 , k
t = t + c(i)**(i-1)
end do
fp = n - t
End Function fp
Integer(Kind=KI) Function fq( n )
Integer(Kind=KI) :: n
integer(Kind=KI) :: t
integer :: k , i , tq
integer , allocatable :: c(:) , q(:)
t = n
k = 1
do
if ( t < 10 ) exit
t = t/10
k = k + 1
end do
allocate( c(k) , q(k) )
t = n
tq = 0
do i = 1 , k
c(i) = mod( t , 10 )
t = t/10
if ( mod(c(i),2)== 0 ) tq = tq + 1
q(i) = tq
end do
t = 0
do i = 1 , k
t = t + q(i)**(i-1)
end do
fq = n - t
End Function fq
End Program www_fcode_cn |