program enshu06d4
  implicit none
  integer :: seireki,tsuki,joutai,bangou,kosuu
  real,dimension(1800) :: kion1retsu,kion1retsu_lowpass
  real :: souwa
  integer,parameter :: mado_haba=12 ! 移動平均をとるデータの数
  integer,parameter :: mado_haba_half=mado_haba/2
  real,dimension(-mado_haba_half:mado_haba_half) :: omomi
  real :: omomi_no_souwa
  integer :: mado_haba_hidari,mado_haba_migi,i
  kosuu = 0
  do
     read(*,'(2i5,i2.2,f6.1)',iostat=joutai)bangou,seireki,tsuki, &
          kion1retsu(bangou)
     if (joutai /= 0) exit
     kosuu = kosuu + 1
  end do
  if (mado_haba /= mado_haba_half*2 ) then ! 奇数個のデータを使う場合
     do i = -mado_haba_half,mado_haba_half
        omomi(i) = 1.0 ! 全ての点を同じ「重み1」で重みつき平均をとる
     end do
  else ! 偶数個のデータを使う場合
     do i = -mado_haba_half+1,mado_haba_half-1
        omomi(i) = 1.0            ! 両端を除いた点は「重み1」
     end do
     omomi(-mado_haba_half) = 0.5 ! 両端はそれぞれ「重み0.5」でとして
     omomi( mado_haba_half) = 0.5 ! 重みつき平均をとる
  end if
  do bangou = 1,kosuu
     mado_haba_hidari & ! 「窓」は左側に何個までとれるか
          = min(mado_haba_half,bangou-1)
     mado_haba_migi   & ! 「窓」は右側に何個までとれるか
          = min(mado_haba_half,kosuu-bangou)
     souwa = 0.0
     omomi_no_souwa = 0
     do i = -mado_haba_hidari,mado_haba_migi
        souwa = souwa+kion1retsu(bangou+i)*omomi(i)
        omomi_no_souwa = omomi_no_souwa+omomi(i)
     end do
     kion1retsu_lowpass(bangou) = souwa/omomi_no_souwa
     write(*,'(i4,2f6.2)')bangou,kion1retsu(bangou),kion1retsu_lowpass(bangou)
  end do
end program enshu06d4