回 帖 发 新 帖 刷新版面

主题:新手求助,迭代过程的错误,很简单的改错

recursive integer function fibonacci(i) result(answer)
        implicit none
        integer,intent(in):: i

        if(i==0) then 
            answer=0
        else if(i==1) then 
            answer=1
        else
            answer=fibonacci(i-1)+fibonacci(i-2) 
        end if
        
    end function fibonacci
    
    program Console9 
    implicit none
    integer::n,i
    integer::fibonacci
    print "(A)","print the number of series you want"
    read(*,*) i
    do i=0,i
        print *,fibonacci(i)
    end do
    end program Console9


错误显示如下:
错误    1     error #6633: The type of the actual argument differs from the type of the dummy argument.    D:\study\研二第一学期\fortran\Console9\Console9\Console9.f90    23    
错误    2     error #6633: The type of the actual argument differs from the type of the dummy argument.   [I]    D:\study\研二第一学期\fortran\Console9\Console9\Console9.f90    35    
错误    3    Compilation Aborted (code 1)    D:\study\研二第一学期\fortran\Console9\Console9\Console9.f90    1    

回复列表 (共3个回复)

沙发

错误百出。

板凳

随便瞄了一眼
integer::fibonacci
error

3 楼


路径里面不能有中文,你改成英文试试

我来回复

您尚未登录,请登录后再回复。点此登录或注册