# 能書き

トランプ大統領の国連演説が良かったので、トランプゲームを作ろうと思いました。

しかし、眠いので途中まで。

## 実行結果　ポーカーゲーム

```  heart    4    club     Q
club     5    heart    5
club     6    club     4
続行するには何かキーを押してください . . .
```

## ソースプログラム

```        deck = [deck(::2), deck(2::2)]
```

```    module m_cards
implicit none
character(len = *), parameter :: mark(*) = ['club', 'diamond', 'heart', 'spade']
character(len = 2), parameter :: num (*) = [' A', ' 2', ' 3', ' 4', ' 5', ' 6', ' 7', ' 8' ,' 9', '10', ' J', ' Q', ' K']
enum, bind(c)
enumerator :: club, diamond, heart, spade
enumerator :: ace,  jack = 11, queen, king
end enum

integer, parameter :: noc = 52, ns = 4, nc = noc / ns
type :: t_card
character(len = len(mark(1))) :: mark
character(len = 2) :: num
end type
contains
type(t_card) function to_card(i)
integer, intent(in) :: i
to_card = t_card( mark((i - 1) / nc + 1), num(nc + modulo(i, -nc)) )
end function to_card
end module m_cards

program Console2
use m_cards
implicit none
type (t_card) :: hands(5, 2)
integer :: i, j, k, n, deck(52)
real :: r
forall (i = 1:noc) deck(i) = i   ! [1:noc]
call random_seed()
call random_number(r)
n = 10 + int(200 * r)
! shuffle
do i = 1, n
deck = [deck(2::2), deck(::2)]
call random_number(r)
n = int(noc * r) + 1
deck = [deck(n:), deck(:n - 1)]
end do
! deal
k = 0
do i = 1, size(hands, 1)
do j = 1, size(hands, 2)
k = k + 1
hands(i, j) = to_card(deck(k))
end do
end do
! print
do i = 1, 5
print "(2(a8, ' ', a, '   '))", hands(i, :)
end do
end program Console2
```