[Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode
Program www_fcode_cn
Implicit None
real :: a(11) = (/1.3,4.3,3.,5.1,6.,7.6,8.,0.6,8.4,12.5,11./)
write(*,*) '[0,2)区间共有:', count( (a>=0.and.a<2) ) , '个数'
!// 其他请参考本句修改
End Program www_fcode_cn
[Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode
program test
real a(1000) !假设有1000个数据
integer i, j, num(7) !假设7个统计区间[0,2),[2,4),[4,6),[6,8),[8,10),[10,12),[12,14)
open(10,file='1.txt')
num = 0
do i = 1, 1000
read(10,*) a(i)
j = a(i)/2.0 + 1
num(j) = num(j) + 1
end do
end program