chap05/kadai2.f90

サンプルコードのダウンロード

 1program answer
 2  implicit none
 3
 4  integer, parameter :: days(12) = &
 5       & (/31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31/)
 6
 7  integer :: i, m, d, doy
 8
 9  write(*, *) 'Input month and day : '
10  read(*, *) m, d
11
12  doy = 0
13  do i = 1, m - 1
14    doy = doy + days(i)
15  enddo
16  doy = doy + d
17
18  write(*, *) 'day of year : ', doy
19
20  stop
21endprogram answer