JB{@2H6E)$A4O`~TW~@AIO4.png (11.47 KB, 下载次数: 284)
Program fcode_demo
Implicit none
integer :: y , m , d , t
Open(12,File="in.txt")
Open(13,File="out.txt")
Do
read( 12 , * , ioStat = t ) y , m , d
if ( t/= 0 ) exit
write( 13 , * ) y , m , d , DaysInYear( y , m , d )
End Do
Close(12)
Close(13)
contains
Integer Function DaysInYear( year , mon , day )
Integer :: year , mon , day
Integer :: DaysInMonth(12) = [31,28,31,30,31,30,31,31,30,31,30,31]
if ( ( (MOD(year,4)==0).and.(MOD(year,100)/=0) ) .or. (mod(year,400)==0) ) then
DaysInMonth(2) = 29
else
DaysInMonth(2) = 28
end if
DaysInYear = sum( DaysInMonth(:mon-1) ) + day
End Function DaysInYear
End Program fcode_demo
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |