Playing cards: Difference between revisions

Added XPL0 example.
m (→‎{{header|Batch File}}: added syntax highlight)
(Added XPL0 example.)
Line 6,900:
Reg_ins(9) // insert the cards here
Return</lang>
 
=={{header|XPL0}}==
<lang XPL0>char Deck(52); \card structure (low 2 bits = suit)
def Players = 4; \number of players to deal to
char Hand(Players, 52); \each player's hand
int Card, N, I, J, T;
char Suit, Royal;
[for Card:= 0 to 52-1 do \make a new deck
Deck(Card):= Card;
for N:= 0 to 10000 do \shuffle the deck
[I:= Ran(52); J:= Ran(52);
T:= Deck(I); Deck(I):= Deck(J); Deck(J):= T;
];
for N:= 0 to 52-1 do \deal from the deck
[Card:= Deck(N);
I:= N/Players;
J:= rem(0);
Hand(J, I):= Card;
];
Suit:= "HDCS "; \print each player's hand
Royal:= "JQK "; \ (= contents of the deck)
for J:= 0 to Players-1 do \e.g: 2D 3C 10C AS KD
[for I:= 0 to 52/Players -1 do
[Card:= Hand(J, I);
N:= Card>>2 + 1; \pip value
if N = 1 then ChOut(0, ^A)
else if N >= 11 then ChOut(0, Royal(N-11))
else IntOut(0, N);
ChOut(0, Suit(Card&3));
ChOut(0, ^ );
];
CrLf(0);
];
]</lang>
 
{{out}}
<pre>
3S 9C 4C 5D KC 9H QS 4H 5C 6H 2C 3C 5S
8D 4S 3H 8C 2D 7C 2S 8H 8S 10D 9S AH JC
6C 10C KH 9D 3D 5H JS 10S 2H 4D 10H 7H JH
QD KS 7S QH 6S JD QC 6D KD AC 7D AS AD
</pre>
 
=={{header|zkl}}==
772

edits