program main implicit none integer :: i,n,maxx,minn,imax,imin,above,below real*8 :: mean type student integer :: v character*15 :: surname end type student type(student), allocatable :: a(:) !1) open(10,file='list.dat') read(10,*) n allocate(a(n)) do i=1,n read(10,*) a(i)%v, a(i)%surname write(*,*) a(i)%v, a(i)%surname enddo write(*,*) '' !2) maxx=17 do i=1,n if (a(i)%v.gt.maxx) then maxx=a(i)%v imax=i endif enddo write(*,*) 'Maximum score is', maxx, 'by student ', a(imax)%surname do i=1,n if (i.ne.imax) then if (a(i)%v.eq.maxx) then write(*,*) 'Maximum score is', maxx, 'by student ', a(i)%surname endif endif enddo minn=31 do i=1,n if (a(i)%v.lt.minn) then minn=a(i)%v imin=i endif enddo write(*,*) 'Mnimum score is', minn, 'by student', a(imin)%surname do i=1,n if (i.ne.imin) then if (a(i)%v.eq.minn) then write(*,*) 'Minimum score is', minn, 'by student ', a(i)%surname endif endif enddo write(*,*) !3) mean=0.d0 do i=1,n mean=mean+a(i)%v enddo mean=mean/dble(n) write(*,*) 'Average score is', mean below=0 above=0 do i=1,n if (a(i)%v.le.mean) then below=below+1 elseif (a(i)%v.gt.mean) then above=above+1 endif enddo write(*,*) below, 'students got a score less than or equal to the average score' write(*,*) above, 'students got a score greater than the average score' deallocate(a) stop end program main