chap04/kadai7.f90

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

 1program answer
 2  implicit none
 3
 4  integer, parameter :: nmax = 200
 5
 6  integer :: i
 7  real(8) :: alpha, da, p
 8
 9  alpha = 1.0
10  da = 1.0e-3
11  do while(alpha < 3.0)
12    alpha = alpha + da
13
14    ! first half
15    p = 0.9
16    do i = 1, nmax / 2
17      p = p + alpha * p * (1 - p)
18    enddo
19
20    ! output latter half
21    do i = nmax / 2, nmax
22      write(*, *) alpha, p
23      p = p + alpha * p * (1 - p)
24    enddo
25  enddo
26
27  stop
28endprogram answer