用 count 函数不是很方便么?
[Fortran] 纯文本查看 复制代码 Program yatou
Implicit None
Integer :: b(10) !10个就够了
Integer :: i, o = 0, p = 0, q = 0, r = 0, s = 0 !建议定义时给初值
do i=1,10
Read(*,*) b(i)
end do!建议用 End Do
!b = [ 68, 44, 5, 5, 5, 5, 6, 6, 7, 78 ]
o = count( b<60.and.b>=0 )
Print *, '不及格人数', o
p = count( b<70.and.b>=60 )
Print *, '60——69', p
q = count( b<80.and.b>=70 )
Print *, '70——79', q
r = count( b<90.and.b>=80 )
Print *, '80——89', r
s = count( b<=100.and.b>=90 )
Print *, '90——100', s
End Program yatou |