Fortran Coder

查看: 836|回复: 1
打印 上一主题 下一主题

[子程序] 实例0831书中说不需要声明就可以用,但是出现报错

[复制链接]

12

帖子

4

主题

0

精华

入门

F 币
46 元
贡献
27 点
跳转到指定楼层
楼主
发表于 2023-10-13 16:06:24 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
[Fortran] 纯文本查看 复制代码
program ex0831
implicit none
integer ::n
write(*,*)'N='
read (*,*)n
write(*,"(I2,'!=',I8)")n,fact(n)
stop
end

contains
recursive integer function fact(n)result(ans)
implicit none
integer ,intent(in)::n

if (n<0)then
ans=-1
return
else if (n<=1)then
ans =1
return
end if
ans=n*fact(n-1)
return
end function fact
end

--------------------Configuration: 21351 - Win32 Debug--------------------
Compiling Fortran...
E:\Fortran\MSDEV98\MyProjects\21351\320020.f90
E:\Fortran\MSDEV98\MyProjects\21351\320020.f90(6) : Error: This name does not have a type, and must have an explicit type.   [FACT]
write(*,"(I2,'!=',I8)")n,fact(n)
-------------------------^
Error executing df.exe.

21351.exe - 1 error(s), 0 warning(s)


分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-14 23:17

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表