本帖最后由 vvt 于 2020-4-24 20:45 编辑
[Fortran] 纯文本查看 复制代码 program www_fcode_cn implicit none
integer , parameter :: NMAX = 2
character(len=9) :: cName(NMAX) , Z
real :: rMax(NMAX) , r
integer :: j
open(10,file='003.txt')
rMax = -huge(rMax)
Do
read(10,*,ioStat=j) z , z , r
if(j/=0) exit
if( any(rMax<r) ) then
j = maxloc( rMax , 1 , rMax<r )
rMax(j:) = [ r , rMax(j:NMAX-1) ]
cName(j:)= [ z , cName(j:NMAX-1) ]
end if
End Do
write(*,'(g0,1x,a)') ((rMax(j),cName(j)),j=1,NMAX)
end program www_fcode_cn
|