|
Program test_contains_localVar
Implicit None
Integer :: i
Do i = 1, 3
Write(*,*) 'ido=',i
Write(*,*) 'fact=',fact(i)
End do
Contains
Function fact(n)
Integer :: 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
出来的结果是:
ido= 1
fact=1
ido=3
i=2
i=3
6
好奇怪啊,为什么主程序里直接跳过2了?最后那个6是哪来的,我输出语句都标注了?
|
|