設問
ジョーカーを含む53枚のトランプからカードを1枚引く動作をシミュレートする スクリプトを作成せよ.
Spade |
Diamond |
Club |
Heart |
数字 | 表示 |
---|---|
1 | Ace |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
6 | 6 |
7 | 7 |
8 | 8 |
9 | 9 |
10 | 10 |
11 | Jack |
12 | Queen |
13 | King |
Ace of Spade |
もしくは,
Joker! |
joker = rand(53) if joker == 0 printf "Joker!\n" else s = rand(4) n = rand(13) if s == 0 suits = "Spade" elsif s == 1 suits = "Diamond" elsif s == 2 suits = "Club" else suits = "Heart" end if n == 0 num = "King" elsif n == 1 num = "Ace" elsif n == 11 num = "Jack" elsif n == 12 num = "Queen" else num = n.to_s end printf "%s of %s\n", num, suits end |
Back |