2个问题,见注释
[Fortran] 纯文本查看 复制代码 Program test_contains_localVar
Implicit None
Integer :: i , s
Do i = 1, 3
Write(*,*) 'ido=',i
s = fact(i) !//避免主程序write中子程序也write
Write(*,*) 'fact=',s
End do
Contains
Function fact(n)
Integer :: i,fact,n,temp!//子程序要单独定义循环变量
temp = 1
Do i = 2, n
Write(*,*) 'i=',i
temp = i*temp
End do
fact = temp
End Function fact
End Program test_contains_localVar |