1program answer
2 implicit none
3
4 integer, allocatable :: score(:)
5 integer :: i, n
6 integer :: best, worst
7 real(8) :: savg, sstd
8
9 read(*, *) n
10
11 allocate(score(n))
12 read(*, *) score
13
14 best = 0
15 worst = 100
16 savg = 0.0_8
17 do i = 1, n
18 best = max(best, score(i))
19 worst = min(worst, score(i))
20 savg = savg + score(i)
21 enddo
22 savg = savg / n
23
24 sstd = 0.0_8
25 do i = 1, n
26 sstd = sstd + (score(i) - savg)**2
27 enddo
28 sstd = sqrt(sstd / n)
29
30 ! 以下のように組み込み関数を用いても良い
31!! best = maxval(score)
32!! worst = minval(score)
33!! savg = sum(score)/real(n, kind=8)
34!! sstd = sqrt(sum((score - savg)**2)/n)
35
36 write(*, *) 'Best : ', best
37 write(*, *) 'Worst : ', worst
38 write(*, *) 'Average : ', savg
39 write(*, *) 'Standard deviation : ', sstd
40
41 deallocate(score)
42
43 stop
44endprogram answer