data.txt文件
座号:1
中文:1英文:2数学:3
座号:2
中文:3英文:4数学:5
代码:、
[Fortran] 纯文本查看 复制代码 module typedef
type student
integer chinese,english ,math
end type
end module
program ex0907
use typedef
implicit none
type(student)::s
character(len=80)::filename="data.txt"
integer,parameter::fileid=10
logical alive
integer ::error
integer::no
inquire(file=filename,exist=alive)
if(.not.alive)then
write(*,*)trim(filename),"doesn't exit"
stop
end if
open (fileid,file=filename)
do while(.true.)
read(fileid,"(5XI2,/,5XI3,6XI3,6XI3)",iostat=error)no,s
if(error/=0)exit
write(*,"(I2'号 中文:'I3'英文:'I3'数学:'I3)")no,s
end do
close(fileid)
stop
end
结果
|