chap04/kadai6.f90

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

 1program answer
 2  implicit none
 3
 4  character(len=128) :: input
 5
 6  do while(.true.)
 7    read(*, *) input
 8    select case(input)
 9    case('apple', 'orange', 'banana')
10      write(*, *) 'food'
11    case('dog', 'cat', 'lion')
12      write(*, *) 'animal'
13    case('car', 'airplane', 'motorcycle')
14      write(*, *) 'vehicle'
15    case('exit')
16      write(*, *) 'Now exit program...'
17      exit
18    case default
19      write(*, *) 'others'
20    endselect
21  enddo
22
23  stop
24endprogram answer